tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dave Robbins" <drobb...@drobbins.net>
Subject servletcontext/path problem
Date Fri, 20 Sep 2002 13:55:24 GMT
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



Mime
View raw message