• Post Reply Bookmark Topic Watch Topic
  • New Topic

intercepting the response stream

 
ht kim
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello.
what i want to do is something like RequestDispatcher.forward method.
but i want to change the forward url's result stream before client browser gets it.
and then the modified result stream would be sent to client browser.
can i set the outputstream of response to memory instead of client socket?
i tried to find that kind of method, but there wasn't.
of course, i think i can make a method that gets the forward url's result stream.
but the problem is that calling that method is another http request,
so i cannot pass the request instance.
therefore informations in request instance should be lost.
is there any good way to solve this problem?
thanks
 
Joe Gilvary
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This sounds like a good chance to learn how
to use Filters in the Servlet 2.3 spec. Does
your servlet environment support the 2.3 spec?
If not, it may have an earlier, proprietary
mechanism of its own to provide the same
functionality.
According to the document at
http://java.sun.com/products/servlet/Filters.html

filters can be used for
Querying the request and acting accordingly
Blocking the request and response pair from
passing any further.
Modifying the request headers and data. You do
this by providing a customized version of the
request.
Modifying the response headers and data. You do
this by providing a customized version of the
response.
That modifying the response data sounds like what
you need.
The Java Pet Store demo from Sun also includes
downloadable code that demonstrates filters.
See the page at
http://java.sun.com/blueprints/code/index.html#java_pet_store_demo
for that.
HTH,
Joe
 
ht kim
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks so much, joe.
i'll try Filters.
and i guess it maybe helpful to me.
:]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!