This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Altering request via Filter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Altering request via Filter" Watch "Altering request via Filter" New topic
Author

Altering request via Filter

David Buitenveld
Greenhorn

Joined: Apr 22, 2003
Posts: 2
Hi all -
I am trying to change and/or add parameters (or attributes) of the request in a doFilter method.. by posting various debug messages, I can see that the filter gets called in the correct order, but my servlet never sees any changes to the request object..
is there a trick? browsing through "more servlets and javaserver pages" I see that there are a few hoops to jump through if you want a filter to process the outbound response - didn't see anything about changing the request though..
thanks for any thoughts
david buitenveld
beluga software cooperative
John Dunn
slicker
Ranch Hand

Joined: Jan 30, 2003
Posts: 1108
Try this:


"No one appreciates the very special genius of your conversation as the dog does."
David Buitenveld
Greenhorn

Joined: Apr 22, 2003
Posts: 2
I think maybe that last code is solving a different problem? Regardless, after using your example, I still cannot see the new attribute in the servlet - I have some code to dump the attribute list like this:
for (Enumeration e = request.getAttributeNames();
e.hasMoreElements() {
out.println(e.nextElement());
}
where out is the request.getWriter().. this never shows anything I add/change in the filter..
thoughts?
thanks

dave
John Dunn
slicker
Ranch Hand

Joined: Jan 30, 2003
Posts: 1108
This worked for me. I did have some confusion as to how things got called in the filter chain so I put in trace prior & after all the doFilter calls. I would suggest that. I also set my filtering to handle only one servlet so it made the testing environment smaller. Hope that helps.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Altering request via Filter
 
Similar Threads
URL Patterns - Trying to understand wildcards
Security Filter
Filters
Blank page returned when filters are used with struts
servlet filter sendRedirect