| Author |
Filter and Struts
|
Wilson Gordon
Ranch Hand
Joined: Apr 07, 2007
Posts: 89
|
|
Hi, I tried to add a filter to my application to filter requests, but it doesn't seem to intercept any request. Is there a problem with using filter and Struts together? How can I get it to work? Thanks.
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26496
|
|
Wilson, No problem. I use filters and Struts. Have you tried a bare bones "Hello World" filter to see if it gets called? If so, I recommend posting your additions for the filter in the web.xml to the servlets forum to ask what is wrong.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Wilson Gordon
Ranch Hand
Joined: Apr 07, 2007
Posts: 89
|
|
Hi Jeane, Thanks for the reply. I added some logging and looks like the filter does get invoked. What I try to achieve is to alter the response to add cookies from the session attributes. To do that, I created a wrapper class that implements the HttpResponseWrapper interface, and passed the wrapped response object into the chain filter. Below the chain filter call, I called addCookie method on the response object. The strange thing is the cookies don't seem to get added. Any idea?
|
 |
Wilson Gordon
Ranch Hand
Joined: Apr 07, 2007
Posts: 89
|
|
Here is my doFilter method code: The cookie doesn't get set for some reason. Any idea? [ October 31, 2007: Message edited by: Wilson Gordon ]
|
 |
Wilson Gordon
Ranch Hand
Joined: Apr 07, 2007
Posts: 89
|
|
I also tried the following and it didn't redirect me to Google. Looks like I can't modify the response for some reason. chain.doFilter(wrappedRequest, wrappedResponse); response.sendRedirect("http://www.google.com"); Anyone know how I could resolve the problem? Thanks.
|
 |
Brent Sterling
Ranch Hand
Joined: Feb 08, 2006
Posts: 948
|
|
What does your web.xml entry look like? - Brent
|
 |
 |
|
|
subject: Filter and Struts
|
|
|