| Author |
read from httpRequest put into httpResponse in Filter?
|
raminaa niilian
Ranch Hand
Joined: Jul 14, 2005
Posts: 550
|
|
Hi Thank you for reading my post I am looking to understand how I can read something from a httprequest and then add the same parameter to that request httpresponse. Is it possible to put my own parameters into http header using this way? for example request A come for filter F and then in filter F I read parameter p from the request A, request will go into endpoint servlet and come back, when it come back I put PP into the response header which is going toward client. Thanks [ December 03, 2007: Message edited by: Bear Bibeault ]
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
Parameters and headers are two separate things. Can you explain, exactly what you are trying to do? There might be a more standard way of doing it.
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
raminaa niilian
Ranch Hand
Joined: Jul 14, 2005
Posts: 550
|
|
Hi Thank you for reply. I want to interpert each request to see whether an specefic httpRequest header attribute like request-number is present or not. if it is present I want to store the number and then let the request go to servlet. when the response of this request come back from the servlet I want to increment request-number and let the response go to client. before i increment the request-number I will check to see what is inside the response. Thanks
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
Again form/querystring parameters and HTTP request headers are two different things. Headers, for the most part, are something that we, as application developers, don't get too involved with. They're generally treated as a low level part of the HTTP protocol. What are you using for a client? A web browser? Or have you written something custom?
|
 |
raminaa niilian
Ranch Hand
Joined: Jul 14, 2005
Posts: 550
|
|
Thank you for reply. I do not want to use QueryString or add changes to real content of the response, But I exchange some values between client (an specific client, it is not a browser) and the server. The scenario or this exchange is like what I explained in my first post. Thanks for your time.
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
Filters are passed references both the request and response objects so you should be able to read and write HTTP headers with: http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpServletRequest.html#getHeader(java.lang.String) and http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpServletResponse.html#setHeader(java.lang.String,%20java.lang.String)
|
 |
 |
|
|
subject: read from httpRequest put into httpResponse in Filter?
|
|
|