tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Smith <d...@cornell.edu>
Subject Re: How to get Request from RequestFacade
Date Thu, 06 Sep 2007 11:52:00 GMT
Ok... do you need them to modify the request and/or response?  Or are 
you trying to pull some information from the original tomcat internals?

I first assumed you were attempting to modify the request or response, 
so a wrapper is ideal.  All you have to do is create a class that 
extends HttpServletRequestWrapper or HttpServletResponseWrapper and 
override the methods you want.  Then in the filter, just instantiate 
your request or response class with the original request or response in 
the constructor.  When you chain to the next filter, just pass on the 
new request and response objects.

--David

Tremal Naik wrote:

>That's the point, I don't know much about request/response wrapping.
>
>I don't need the Facade itself, what I need are the "real" Catalina
>Request/Response objects hidden behind it. I don't know how to get
>them from inside a Filter.
>
>Thanks,
>
>TN
>
>2007/9/6, David Smith <dns4@cornell.edu>:
>  
>
>>May I ask what exactly you want to do with the facade?  Seems like you
>>could do what you want with a request or response wrapper instead.
>>
>>--David
>>
>>Tremal Naik wrote:
>>
>>    
>>
>>>Hello,
>>>I'v been using a valve to perform license checking in my web
>>>application. The method invoke(Request request, Response response) had
>>>access to the Request and Response objects, allowing me to perform
>>>some advanced operations. For instance, I made use of instructions
>>>like:
>>>
>>>Session catalinaSession = request.getSessionInternal(false);
>>>catalinaSession.access();
>>>
>>>or
>>>
>>>Session[] managedSessions = request.getContext().getManager().findSessions();
>>>
>>>Now, I'm moving the license validation code to a Filter. How do I
>>>access org.apache.catalina.connector.Request/Response in the method
>>>doFilter()? I see that I can only cast to a RequestFacade object:
>>>
>>>public void doFilter(ServletRequest sRequest, ServletResponse
>>>sResponse, FilterChain chain)
>>>        throws IOException, ServletException
>>>  {
>>>     RequestFacade cRequest = (RequestFacade) sRequest;
>>>     ......
>>>
>>>
>>>but now, I cannot use the Facade to access the Request. How can I
>>>solve this problem? Is it desirable accessing Catalina specific object
>>>      
>>>
>>>from a Filter? Should I rewrite my code/ redesign my license
>>    
>>
>>>validation framework? It is a very complex one, hance it may require
>>>some effort. May you redirect me to some useful articles/resources?
>>>
>>>
>>>Many thanks
>>>
>>>
>>>
>>>      
>>>
>>---------------------------------------------------------------------
>>To start a new topic, e-mail: users@tomcat.apache.org
>>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>    
>>
>
>
>  
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message