Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Altering request via Filter

 
David Buitenveld
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this:
 
David Buitenveld
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic