You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Jonathan Pierce <Jo...@seagram.com> on 2001/08/15 02:32:44 UTC

Servlet Forward to Self? 4.0b7

I'm not sure whether it is legal, but Tomcat 4.0b7 doesn't like it very much. 

I'm trying to forward a request back to the same servlet with a different query
string that dispatches the way the request is handled within the servlet.

Tomcat4.0b7 gets an error trying to allocate the servlet again from the invoker.

In my servlet service handler:

String theNewURL = "/servlet/" + getClass ().getName () + "?GOTO=NextScreen";
theNewURL = theResponse.encodeUrl (theNewURL);
ServletContext theServletContext = theDBServlet.getServletContext ();
theServletContext.getRequestDispatcher (theNewURL).forward (theRequest,
theResponse);

Re: Servlet Forward to Self? 4.0b7

Posted by Dmitri Colebatch <di...@bigpond.net.au>.
On Tue, 14 Aug 2001, Jonathan Pierce wrote:
> String theNewURL = "/servlet/" + getClass ().getName () + "?GOTO=NextScreen";
> theNewURL = theResponse.encodeUrl (theNewURL);
> ServletContext theServletContext = theDBServlet.getServletContext ();
> theServletContext.getRequestDispatcher (theNewURL).forward (theRequest,
> theResponse);

why are you encoding the url?  DOing that will cause ? and = to be encoded
as %whatever; so the query string wont be interpreted as you
intend.  Having said that I'm not sure if it would work anyway (o:  Why
not set an attribute in the request and then forward the request as is and
have the servlet look for that attribute and act accordingly?

btw - isn't this a tomcat-user question?  

cheesr
dim