File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Handling request parameters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Handling request parameters" Watch "Handling request parameters" New topic
Author

Handling request parameters

Jari Timonen
Ranch Hand

Joined: Jan 16, 2004
Posts: 232
Hello everybody,

Is it possible to handle request-parameters in ServletFilter before they're sent to servlet?



Since String is immutable - I can't just go and change the value.
Mayby with extending HttpServletRequestWrapper ?
[ June 25, 2008: Message edited by: Jari Timonen ]

SCJP 5.0, SCJD URLyBird 1.3.3, OCMJEA 5 (SCEA) Factory Homes
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

you can use inside filter.

you need to typecast ServletRequest to HttpServletRequest

then you can do your stuff //

Thanks & Regards,
seetharaman v
Jari Timonen
Ranch Hand

Joined: Jan 16, 2004
Posts: 232
Originally posted by seetharaman venkatasamy:
you can use inside filter.

you need to typecast ServletRequest to HttpServletRequest

then you can do your stuff //

Thanks & Regards,
seetharaman v


There's no modification methods to request parameters in HttpServletRequest.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Mayby with extending HttpServletRequestWrapper ?



You're correct.
Request parameters are read-only in HttpServletRequest.

If, by 'handling', you mean altering, then yes wrapping the request and adding your own methods is typically how this is done.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Handling request parameters