I need to write a Servlet or Filter class that can access the org.apache.catalina.connector.Request object, which is wrapped in the RequestFacade object specified for my servlet. Casting does not work because RequestFacade is not a subclass of Request.
I need this because I'm trying to call the setRequestedSessionId () Request method, and this does not seem to be part of the Http servlet specification. The reason I need to do this is because the session identifier is included in the URL under a different name than JSESSIONID. I cannot change the URL or parameter name, so I am trying to associate the request with the correct session by retrieving the session ID and calling Request.setRequestedSessionId ().
I really solved the problem using the Valve subclass, but I don't like using Valve because, as far as I can tell, I need to install the Valve subclass in the Tomcat / server / classes directory instead of packing it with the rest of my webapp. If there was a portable way to do this in different servlet containers, that would be great, but for now, I have come to terms with making this Tomcat-specific.
Here is the valve code:
public class SessionSetter extends ValveBase {
public void invoke( Request request, Response response ) throws IOException, ServletException {
String sessionId = request.getParameter( "whatever" );
request.setRequestedSessionId( sessionId );
}
}
Is there a way to do the same in a servlet or in a filter? Or is there some way to package the Valve class in my .war application file?
source
share