www.webdeveloper.com
Results 1 to 12 of 12

Thread: Java redirect script

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Posts
    85

    Java redirect script

    Hi

    I found this script:


    <script language='JAVASCRIPT' type='TEXT/JAVASCRIPT'>
    <!--
    if ((navigator.appName=="Microsoft Internet Explorer") || (navigator.appName=="Netscape"))
    {
    if (navigator.appName=="Microsoft Internet Explorer")
    window.location = "pc/index.htm";
    else
    window.location = "pc/index.htm";
    }
    else
    window.location = "phone/index.htm";
    //--></script>


    Unfortunately, it's in Javascript and I need it in Java.

    Does anybody know the Java code for this Javascript code?

    Thanks

  2. #2
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    It would look something like this:
    Code:
    <%
    if (request.getHeader("user-agent").indexOf("MSIE") > -1)
        response.sendRedirect("pc/index.htm");
    else if (request.getHeader("user-agent").indexOf("Firefox") > -1)
        response.sendRedirect("pc/index.htm");
    else
        response.sendRedirect("phone/index.htm");
    %>

  3. #3
    Join Date
    Sep 2004
    Posts
    85
    It doesn't seem to work, look:

    http://www.voordeligewebsites.com/mpoints/

    Does anybody know what I am doing wrong?

    Thanks!

  4. #4
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    6,123
    rays suggestion above presumes that you have a server that understands jsp tags and is a servlet container...the above code should work from any web server that supports jsp/servlet technologies.
    Cheers

    Khalid

    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

  5. #5
    Join Date
    Sep 2004
    Posts
    85
    Originally posted by Khalid Ali
    rays suggestion above presumes that you have a server that understands jsp tags and is a servlet container...the above code should work from any web server that supports jsp/servlet technologies.
    Well, it looks like my server doesn't support this. Do you guys know any other code that would work?

    Thanks in advance for your efforts!

  6. #6
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    6,123
    try finding out that if your server supports PHP(Iam guessing it does).If it does then post your question in PHP and you will be all set.
    Cheers

    Khalid

    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

  7. #7
    Join Date
    Sep 2004
    Posts
    85
    Well, the problem is it has to be Java. This is why:

    I'm working with a client who's in the UMTS business. I have to create for him two different sites that will be accesible on one domainname. So I have to use a redirect script.

    The problem is these UMTS phones only support Java and HTML. So I have to use Java to redirect the user to the right website.

    So, when a PC is visiting the website he will be directed to the big website and when a UMTS phone is visiting the website he will be directed to the small website.

    So I need a Java applet that sais that when you are visiting the site with the IE or with Netscape you'll go to the big site, otherwise you'll go to the other site. What also would be good is that when you are visiting with a screen resolution less than 640 x 480 you go to the small site and otherwise you go to the bg site.

    Several days now I'm looking on the internet for the right applet and I could not find it. I promised my client that I would implement such a Java redirect script so I really hope you guys can help me out.

    Thanks!

  8. #8
    you have something against opera?

  9. #9
    Join Date
    May 2004
    Location
    Manhattan NY
    Posts
    6,028
    Yep. Most of em are in Italian. I'm not fluent in Italian.

  10. #10
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    Originally posted by Frank1984
    Well, the problem is it has to be Java. This is why:

    I'm working with a client who's in the UMTS business. I have to create for him two different sites that will be accesible on one domainname. So I have to use a redirect script.

    The problem is these UMTS phones only support Java and HTML. So I have to use Java to redirect the user to the right website.

    So, when a PC is visiting the website he will be directed to the big website and when a UMTS phone is visiting the website he will be directed to the small website.

    So I need a Java applet that sais that when you are visiting the site with the IE or with Netscape you'll go to the big site, otherwise you'll go to the other site. What also would be good is that when you are visiting with a screen resolution less than 640 x 480 you go to the small site and otherwise you go to the bg site.

    Several days now I'm looking on the internet for the right applet and I could not find it. I promised my client that I would implement such a Java redirect script so I really hope you guys can help me out.

    Thanks!
    One way or the other the client hits this web site with a web browser. This detection and redirection must be done on the server side in order to eliminate the need for Javascript or Java applet capabilities on the browser. If your client brings this page up as a JSP running on Tomcat then my solution will work and it will be the cheapest, most robust way to satisfy your stated requirement. It will also keep them in their Java comfort zone although exactly the same thing could be accomplished by ANY server-side technology; PHP, ASP, CGI, etc.

  11. #11
    Join Date
    Sep 2004
    Posts
    85
    Originally posted by ray326
    It would look something like this:
    Code:
    <%
    if (request.getHeader("user-agent").indexOf("MSIE") > -1)
        response.sendRedirect("pc/index.htm");
    else if (request.getHeader("user-agent").indexOf("Firefox") > -1)
        response.sendRedirect("pc/index.htm");
    else
        response.sendRedirect("phone/index.htm");
    %>
    So if my server support the stuff you mentioned above, then all I have to do is put the script above in the header of an html document and it should work.

  12. #12
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    Yea, any JSP should do for that. You can do it with any server-side technology; the ASP or PHP versions would look very little different. It just depends what you've got available on that particular server. Since we're talking Java here that's why I did it with JSP.
    Last edited by ray326; 09-29-2004 at 01:07 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles