• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

read parameter in filter and servletinputstream in servlet

 
Peter Venema
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Peter Venema
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic