Brij,

I think I saw a usable filter solution when reading through the code of
Security Filter.  If I recall correctly, their filter code uses the
HttpServletRequestWrapper class and adds their own getUserPrincipal()
orverloading method.  Surely you could do the same with your
getServletPath() by overriding it in a subclass of
HttpServletRequestWrapper.

The Java code this model is class
org.securityfilter.filter.SecurityRequestWrapper in CVS at:
http://cvs.sourceforge.net/viewcvs.py/securityfilter/securityfilter/src/shar
e/org/securityfilter/filter/SecurityRequestWrapper.java?rev=1.9&view=auto

To implement the HttpServletRequestWrapper subclass within a filter, see
org.securityfilter.filter.SecurityFilter in CVS at:
http://cvs.sourceforge.net/viewcvs.py/securityfilter/securityfilter/src/shar
e/org/securityfilter/filter/SecurityFilter.java?rev=1.23&view=auto

Regards,
David

-----Original Message-----
From: Brij Naald [mailto:[EMAIL PROTECTED]
Sent: Saturday, December 04, 2004 3:53 PM
To: [EMAIL PROTECTED]
Subject: RE: Filter/...

My application needs to know the path of the servlet which is going to be
called.
Therefore the filter does:

setLastServlet(((HttpServletRequest)request).getServletPath());

and then the filter invokes the servlet wtih a wrapper around its request

The wrapper overrides the
public Object getAttribute(String name)

and only gives access to the attribute with name 'name' if the servlet which
is called has the right path for that attribute. Therefore the wrapper needs
to now the 'LastServlet'.

(So the problem is that the filter is only invoked at the beginning of the
request. When a servlet does dispatcher.include, the setLastServlet of the
filter won't be called anymore, and the "LastServlet" isn't the correct one
anymore)

--------------------------
>Interesting issue. Anyway, can't think of anything that solves it in a
>clean
>way.
>
>If you give me (if you can) further information about what your filter
>does,
>I could give it  a try at thinking about an alternative solution.
>
>Cheers,
>
>F.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to