You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Dave Robbins <dr...@drobbins.net> on 2002/09/20 15:55:24 UTC

servletcontext/path problem

Hi Folks,

I've posted this before and still haven't figured it out.
Maybe you can help this time

I'm using Forte 4.0 and trying to mess with Model 2 jsp/servlet
architecture
I've got a file index.jsp in my top level directory
index.jsp contains a link to a servlet "myServlet" 
the "myServlet" servlet is in WEB-INF/classes in myPackage
the function in the servlet that handles the request executes this
code

        javax.servlet.ServletContext sc;
	javax.servlet.RequestDispatcher rd;
	
	try
	{
	    sc = getServletContext();
            rd = sc.getRequestDispatcher("/foo.jsp"); 
            rd.forward(request, response);
        }
	catch(Throwable theException)
	{
        }

foo.jsp is in the top level directory with index.jsp and this all
works correctly, when you click the link in index.jsp, foo.jsp is
displayed.
Now I put a link in foo.jsp to index.jsp

<a href'"index.jsp">Back to Top<a>

when I mouse over this link the address it points at is 

http://localhost:8081/servlet/index.jsp

which is wrong.
the address displayed in the location window at this point says

http://localhost:8081/servlet/myPackage.myServlet
The docs from Sun for RequestDispatcher.forward() say

For a RequestDispatcher obtained via getRequestDispatcher(), the
ServletRequest object has its path elements and parameters adjusted to
match the path of the target resource.

this sounds to me like when control was passed to foo.jsp, the path
should have been set back to http://localhost:8081/

I kinda think the problem has something to do with a servlet mapping entry 
in web.xml, so far this is all being handled by Forte. When I try to read 
documentation on this stuff it's a tiny bit obtuse. Can somebody help me 
out here.

The .war file is tiny so I attached it

Dave