Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Relative URIs in JSP/Servlet Web Application

843838Nov 16 2005 — edited Nov 16 2005
Hi all,

I have a web application running on Tomcat with the following directory structure...

All jsp files in...
Tomcat\webapps\myweb\*.jsp

All servlet class files in...
Tomcat\webapps\myweb\servlet\WEB-INF\classes\

I use the following code construct a lot in my servlets...
myRelativeURL = TWJspConstants.LOGIN_JSP_PAGE;
getServletConfig().getServletContext().getRequestDispatcher(myRelativeURL).forward(request, response);

In the above case, TWJspConstants.LOGIN_JSP_PAGE = "/login.jsp";

Now, I have a jsp page "Tomcat\webapps\myweb\login_failure.jsp", which needs to contain a hyper-link to TWJspConstants.LOGIN_JSP_PAGE.

But when I use it, the hyperlink becomes "http://localhost/login.jsp" rather than "http://localhost/myweb/login.jsp".

I can hardcode the hyperlink, but I dont want to do that.

Can anyone please explain how to deal with relative URIs when it comes to servlets and jsps.

Thanks,
Joe.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 14 2005
Added on Nov 16 2005
3 comments
226 views