Hi!
You can modify the request in one way. You can add/delete or modify the request attribute (see set/getAttribute(String s, Object o) This method is derived from ServletRequest in the HTTPServletRequest) and pass the request through the filters and do whatever you want with the data you put in the Object.
http://www.java2s.com/Code
Regards,
Tomas Helgi
Main Topics
Browse All Topics





by: kayahrPosted on 2008-09-07 at 09:57:08ID: 22412015
You can't modify the request directly. Simply because it has no setters for the stuff you want to do. But there is a special class for this purpose: HttpServletRequestWrapper. Create a class which extends this class (You may call it MyHttpServletRequest or something like that). Then override the methods you need (getQueryString() for example) so they return the desired modified data. In the filter you can now do this:
st); quest, response);
MyHttpServletRequest newRequest = new MyHttpServletRequest(reque
filterChain.doFilter(newRe
Now all subsequent filters and servlets get your modified request object instead of the original one.