-
redirect to html page
hi i am having some problems redirecting from one servlet to another
if i use
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
Code:
C:\tomcat\apache-tomcat-6.0.18\webapps\coffee\WEB-INF\classes\display.html
i have tried using this , plus relative paths
ie
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
-
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.
-
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
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 :)
-
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.