This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 18541
    
    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
 
Similar Threads
Struts help
RequestDispather?
how to bring variable from previous session to next session
Paths in Tomcat standalone mode
J2ME connecting database in Server using Servlet