Results 1 to 4 of 4
  1. #1
    simo_mon is offline Member
    Join Date
    Dec 2008
    Posts
    50
    Rep Power
    0

    Default redirect to html page

    hi i am having some problems redirecting from one servlet to another

    if i use

    Java Code:
    response.sendRedirect("google");
    ( i had the www here with the com at the end but was unable to post )
    it works fine, but i am trying to redirect to a page that i have locally on tomcat
    called display.html

    the absolute path is
    Java Code:
    C:\tomcat\apache-tomcat-6.0.18\webapps\coffee\WEB-INF\classes\display.html

    i have tried using this , plus relative paths

    ie

    Java Code:
    response.sendRedirect("display.html");
    response.sendRedirect("/display.html");
    response.sendRedirect("classes/display.html");
    response.sendRedirect("/classes/display.html");
    response.sendRedirect("coffee/classes/display.html");
    none of which work ??

    1st question .

    is the classes folder the right spot for the html pages as well

    ie coffee/classes/display.html

    2nd question

    how do i access it in this position

  2. #2
    devin is offline Member
    Join Date
    Feb 2009
    Posts
    13
    Rep Power
    0

    Default

    I think classes is not a good place for an HTML file. You should create a directory underneath WEB-INF called HTML or something like that. At least that is what I do.

    I think the problem is that sendRedirect needs a full URL (not file path on the server) as it results in a completely new Request for the client.

    You might want to try the "request.forward" method, but I am not exactly sure what you are trying to achieve.

    I am new to tomcat and JSP but I hope that helps.

  3. #3
    simo_mon is offline Member
    Join Date
    Dec 2008
    Posts
    50
    Rep Power
    0

    Default

    i think your right !!!!

    i don't think that you can redirect to a html that's on your local machine....

    i used the forward method to go directly to a servlet page

    Java Code:
    String path= "/display";
    
    RequestDispatcher dispatcher =servletContext().getRequestDispatcher(path);
    
    dispatcher.forward(request,response);
    and it worked a treat :):):)


    the whole idea is that i am redirecting from a logon page to a display page, which displays tables from a data base ...

    thanks again for the help :)

  4. #4
    devin is offline Member
    Join Date
    Feb 2009
    Posts
    13
    Rep Power
    0

    Default

    Glad I could be of help. I am always getting help from other people so it is nice to return the favour.

    You can redirect to HTML on your local machine you just need the full URL to that page, same as if you were browsing to it.

Similar Threads

  1. How to open html page?
    By smartsubroto in forum New To Java
    Replies: 8
    Last Post: 08-16-2012, 12:13 PM
  2. Redirect page in web service
    By bluesheeva in forum Advanced Java
    Replies: 3
    Last Post: 02-03-2009, 11:56 PM
  3. Redirect Page in SOAP Message Handler
    By bluesheeva in forum Advanced Java
    Replies: 0
    Last Post: 12-28-2008, 12:43 PM
  4. redirect page within a java applet
    By paul in forum Java Applets
    Replies: 1
    Last Post: 08-07-2007, 05:11 AM
  5. HTML page
    By bbq in forum New To Java
    Replies: 1
    Last Post: 07-05-2007, 03:46 AM

Posting Permissions

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