Is there a way to modify the current context path that a servlet is running in before forwarding a request to a JSP page? Here's the scenario: I have a controller servlet that is accessed as follows: http://localhost:8080/myapp/myservlet And the page I want to forward is at: http://localhost:8080/myapp/myfolder/mypage.jsp Forwarding it via a RequestDispatcher works fine: // Forward the request to the proper Url RequestDispatcher dispatcher = req.getRequestDispatcher( "/myfolder/mypage.jsp" ); dispatcher.forward( req, res ); But the page itself references other pages and resources relative to it - mypage.jsp: images/myimage.gif otherpage.jsp The URLs of those resource are: http://localhost:8080/myapp/myfolder/images/myimage.gif http://localhost:8080/myapp/myfolder/otherpage.jsp Because the URL of the request is http://localhost:8080/myapp/myservlet These resources cannot be found - it assumes that the resources are at: http://localhost:8080/myapp/images/myimage.gif http://localhost:8080/myapp/otherpage.jsp *Note the absence of the "myfolder".. Here are my workarounds: 1. Reference every resource in the jsp page as "myfolder/resource" - but then my JSP development environment is messed up (cannot preview) 2. Map a new URL to the servlet in the web.xml file "/myfolder/myservlet" and then somehow send a redirect to the new URL when some first connects, so it will look like this: http://localhost:8080/myapp/myfolder/myservlet I am looking for a way to programmatically tell the Servlet Context where its Context Path is before the forward, but I am unable to find the proper function calls.. Any suggestions would be greatly appreciated! Thanks, Steve --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]
