wood burning stoves*
The moose likes Servlets and the fly likes Forwarding from a Servlet to a JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Forwarding from a Servlet to a JSP" Watch "Forwarding from a Servlet to a JSP" New topic
Author

Forwarding from a Servlet to a JSP

Robert Stone
Greenhorn

Joined: Jan 06, 2011
Posts: 25
Everyone,

I am using the following code to forward from a Servlet to a JSP



and it works fine however when I get to the JSP the url is still in the context of the servlet

http://www.mywebsite.org/servlet/MyServlet

So, as a result the page is all a mess because it can't find the style sheet in the location "css/main.css" or any of the images in the "images/*.png" location because it needs to look in the location "/images/*.png" but the problem is that the first time the user hits this page it is not in the context of the servlet so everything needs to be in the former locations. If/When we return to the page because the user forgot some form data that is when there is a problem.

How can I fix this issue? Any help again will be greatly appreciated!

Thanks, in advance!

Robert



Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18564
    
    8

The question you ask is this question in the Servlet FAQ: Relative Links.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Forwarding from a Servlet to a JSP