thanks for the help,
But the problem remains. The SecurityFilter will put a wrapper around the request, but my filter also wants to set some attributes (the lastServlet) right.


Example:
Assume that you type in /servlet1 in your browser. In that case the filter will get called, it will put the wrapper around the request, and then forward the control to servlet1.


But if servlet1 contains the code:
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/servlet2"); dispatcher.include(request, response);


Then the filter will not be called again, and the control will be passed directly to servlet2

That way, my application will not get the update that servlet2 is called.

Do you see a solution for this?

Thanks a lot already!

-----------------------------------------
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.

_________________________________________________________________
Koop geen kat in een zak. Probeer alles 14 dagen bij jou thuis. http://linkstat.neckermann.de/go.mb1?benl_11294



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



Reply via email to