setRequest method on HttpServletRequestWrapper

2010-04-14 Thread Unmesh Joshi
Hi,

I was going through tomcat source code. (Specifically
ApplicationDispatcher.java). The way HttpServletRequestWrapper is used
there, puzzled me. What is the intent of all the methods of
HttpServletRequestWrapper class in
servlet api?
Specifically HttpServletRequestWrapper's setRequest method looks like
exposed only for container writers. It will never work if develoepers
use this method in their filter to wrap the request (for something
like url rewriting). What do you think is the intent of exposing this
method to public?

I was actually thinking if its possible to write Url rewriter (like
mod_rewrite) using J2EE API. (request.forward does actually the same
thing, but its container controlled).

Thanks,
Unmesh

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



Re: setRequest method on HttpServletRequestWrapper

2010-04-16 Thread Unmesh Joshi
>>>You have to create your own subclass of HttpServletRequestWrapper.
>>Note also, that the Servlet specification says something about
>>wrapping and unwrapping the requests and responses.
E.g., SRV.6.2.2, SRV.9.9.1 in the Servlet 2.5 specification.

Servlet specification does not talk about overriding getRequestURI,
getRequestURL or getServletPath methods. Also nothing about setRequest
method.
These methods are used by tomcat container for implementing request
forwarding and include.
My question was, why these are available on API for developers?
Overriding these methods will never work, in case

>>Note, that there is already one such well-known library,
>>http://tuckey.org/urlrewrite/

UrlRewriteFilter uses request forwarding and include. It does not (and
can not) use request wrapping.
Just a note, UrlRewriteFilter can not be used with Struts 2.1, because
Struts 2.1 uses servlet filters as controllers and we can not get
request dispatcher for filters.
This is also my second question. Why use servlet filter as controller?
Is struts 2.1 breaking servlet specification?

Thanks,
Unmesh

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



Re: setRequest method on HttpServletRequestWrapper

2010-04-16 Thread Unmesh Joshi
> Filters can be called for forwarded and included requests, if you map
> them in certain way (something like INCLUDE).
> See the Servlet spec for details.  SRV.6.2.5
But you cant get dispatchers for filters. UrlRewriteFilter gets a
dispatcher (so rewrtten url must have a servlet or jsp handler).

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



Re: setRequest method on HttpServletRequestWrapper

2010-04-16 Thread Unmesh Joshi
Yes. On tomcat u get dispatcher for DefaultServlet if there is no
servlet mapping for the url. Typically on Struts2 all the urls get
handled in StrutsExecuteFilter and u dont get dispatcher go that
filter.

On Sat, Apr 17, 2010 at 7:11 AM, Konstantin Kolinko
 wrote:
> 2010/4/17 Unmesh Joshi :
>>> Filters can be called for forwarded and included requests, if you map
>>> them in certain way (something like INCLUDE).
>>> See the Servlet spec for details.  SRV.6.2.5
>> But you cant get dispatchers for filters. UrlRewriteFilter gets a
>> dispatcher (so rewrtten url must have a servlet or jsp handler).
>
> Have you tried?
>
> -
> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: dev-h...@tomcat.apache.org
>
>

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



Re: setRequest method on HttpServletRequestWrapper

2010-04-16 Thread Unmesh Joshi
StrutsExecuteFilter is mapped to *


struts2-execute
/*
  

SRV.15.2.5 explains RequestDispatcher as follows. It does not say u
can (or can not) get request dispatcher for filters. But I think
Filters do not match definition of 'Resource' in SRV. Resources are
either servlets, jsps or static content.

SRV.15.2.5  RequestDispatcher
  public interface RequestDispatcher
  Defines an object that receives requests from the client and sends them to any
  resource (such as a servlet, HTML file, or JSP file) on the server.
The servlet con-
  tainer creates the RequestDispatcher object, which is used as a
wrapper around a
  server resource located at a particular path or given by a particular name.
  This interface is intended to wrap servlets, but a servlet container
can create
  RequestDispatcher objects to wrap any type of resource.


On Sat, Apr 17, 2010 at 8:03 AM, Konstantin Kolinko
 wrote:
> 2010/4/17 Unmesh Joshi :
>> Yes. On tomcat u get dispatcher for DefaultServlet if there is no
>> servlet mapping for the url. Typically on Struts2 all the urls get
>> handled in StrutsExecuteFilter and u dont get dispatcher go that
>> filter.
>>
>> On Sat, Apr 17, 2010 at 7:11 AM, Konstantin Kolinko
>>  wrote:
>>> 2010/4/17 Unmesh Joshi :
>>>>> Filters can be called for forwarded and included requests, if you map
>>>>> them in certain way (something like INCLUDE).
>>>>> See the Servlet spec for details.  SRV.6.2.5
>>>> But you cant get dispatchers for filters. UrlRewriteFilter gets a
>>>> dispatcher (so rewrtten url must have a servlet or jsp handler).
>>>
>>> Have you tried?
>>>
>>> -
>>> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
>>> For additional commands, e-mail: dev-h...@tomcat.apache.org
>>>
>
> And how your StrutsExecuteFilter is mapped in web.xml ?
>
> -
> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: dev-h...@tomcat.apache.org
>
>

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



Re: setRequest method on HttpServletRequestWrapper

2010-04-17 Thread Unmesh Joshi
Sorry for sending all these emails on this list.. I will take the
discussion on user list.

But my original question is still valid for dev list. Is
HttpServletRequestWrapper's setRequest method only for container
writers? Because it will never work for users. (At least not on
Tomcat, because of the way it had implemented ApplicationDispatcher.

Thanks,
Unmesh

On Sat, Apr 17, 2010 at 2:29 PM, Mark Thomas  wrote:
> Please take this to the users list. It is off-topic for the dev list.
>
> Mark
>
> On 17/04/2010 04:09, Unmesh Joshi wrote:
>>
>> StrutsExecuteFilter is mapped to *
>>
>> 
>>     struts2-execute
>>     /*
>>   
>>
>> SRV.15.2.5 explains RequestDispatcher as follows. It does not say u
>> can (or can not) get request dispatcher for filters. But I think
>> Filters do not match definition of 'Resource' in SRV. Resources are
>> either servlets, jsps or static content.
>>
>> SRV.15.2.5      RequestDispatcher
>>   public interface RequestDispatcher
>>   Defines an object that receives requests from the client and sends them
>> to any
>>   resource (such as a servlet, HTML file, or JSP file) on the server.
>> The servlet con-
>>   tainer creates the RequestDispatcher object, which is used as a
>> wrapper around a
>>   server resource located at a particular path or given by a particular
>> name.
>>   This interface is intended to wrap servlets, but a servlet container
>> can create
>>   RequestDispatcher objects to wrap any type of resource.
>>
>>
>> On Sat, Apr 17, 2010 at 8:03 AM, Konstantin Kolinko
>>   wrote:
>>>
>>> 2010/4/17 Unmesh Joshi:
>>>>
>>>> Yes. On tomcat u get dispatcher for DefaultServlet if there is no
>>>> servlet mapping for the url. Typically on Struts2 all the urls get
>>>> handled in StrutsExecuteFilter and u dont get dispatcher go that
>>>> filter.
>>>>
>>>> On Sat, Apr 17, 2010 at 7:11 AM, Konstantin Kolinko
>>>>   wrote:
>>>>>
>>>>> 2010/4/17 Unmesh Joshi:
>>>>>>>
>>>>>>> Filters can be called for forwarded and included requests, if you map
>>>>>>> them in certain way (something likeINCLUDE).
>>>>>>> See the Servlet spec for details.  SRV.6.2.5
>>>>>>
>>>>>> But you cant get dispatchers for filters. UrlRewriteFilter gets a
>>>>>> dispatcher (so rewrtten url must have a servlet or jsp handler).
>>>>>
>>>>> Have you tried?
>>>>>
>>>>> -
>>>>> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
>>>>> For additional commands, e-mail: dev-h...@tomcat.apache.org
>>>>>
>>>
>>> And how your StrutsExecuteFilter is mapped in web.xml ?
>>>
>>> -
>>> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
>>> For additional commands, e-mail: dev-h...@tomcat.apache.org
>>>
>>>
>>
>> -
>> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
>> For additional commands, e-mail: dev-h...@tomcat.apache.org
>>
>
>
> -
> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: dev-h...@tomcat.apache.org
>
>

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org