Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Filters applied, called twice sometimes ...

843841Aug 21 2004 — edited Oct 12 2004
Hi,

I have a small problem which give me headhache...

I'm using a filter to make pre (authentification) and post processing (output the webpage using a XSL transformation).
skeleton :
... doFilter ...
//authentification
chain.doFilter()
//transformation and display

When i'm aslink for a webpage (with a visitor account) there is no problem .., the webpage is displayed properly and the filter is called once ! perfect !

but after my authentification (put a variable containing information onto the session with
"sessionMgr.setSessionUser(session, user);") when I call the same webpage as before the webpage is displayed properly (that's a good point) but I saw in the tomcat console that after the end of the filter , the filter is called again with the same request or null sometimes .... GRRRRR

I read John Hunter article about filters and in its clickstream exampl is using this tips :
// Ensure that filter is only applied once per request.
if (request.getAttribute(FILTER_APPLIED) == null) {
request.setAttribute(FILTER_APPLIED, Boolean.TRUE);
HttpSession session = ((HttpServletRequest)request).getSession();
Clickstream stream = (Clickstream)session.getAttribute("clickstream");
stream.addRequest(((HttpServletRequest)request));
}
at the start of this filter ...

can I have more explanation about this stuff ...
I really don't understand why this happened ... it seems linked to the session management but I have no proof ...
I find out hard to debug and hard to explain so
THANKS A LOT FOR YOUR SUPPORT :)

see ya
Fran�ois (french guy so sorry for the english)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 9 2004
Added on Aug 21 2004
7 comments
1,153 views