aspose file tools*
The moose likes Servlets and the fly likes read parameter in filter and servletinputstream in servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "read parameter in filter and servletinputstream in servlet" Watch "read parameter in filter and servletinputstream in servlet" New topic
Author

read parameter in filter and servletinputstream in servlet

Peter Venema
Greenhorn

Joined: Dec 02, 2002
Posts: 6
Hello,

I've the following problem:
I've got a third party servlet (ArcIMS servlet created by ESRI).

I'd like to place a javax.servlet.Filter before the servlet. The filter should read a parameter and next pass the request to the servlet again.

But.... once I read a parameter, the serlvet lost all parameters. From decompiling the servlet I learned that it probably reads the servlet inputstream. So creating a requestwrapper won't work.

Does anybody have a creative idea how to solve this problem???

Cheers,

Peter
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You are correct, if the servlet needs to read the input stream, then, reading any parameters will break it.

What does this servlet do?
Does it deal with a multi-part encoded post?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Peter Venema
Greenhorn

Joined: Dec 02, 2002
Posts: 6
The servlet reads (among other parameters) an XML message and processes it.
The XML can be send as a simple parameters but it can be send direct as well.

Well, whatever. The customer wanted a logging system, but I guess we should look for other solutions, a Filter is no option.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12822
    
    5
You could always have the Filter read the whole body to a byte[] buffer - with the whole thing in memory you could parse it repeatedly in various ways - for example in a custom getParameterMap method - and still be able to provide an InputStream to the original servlet.

Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: read parameter in filter and servletinputstream in servlet