aspose file tools
The moose likes Servlets and the fly likes Adding Custom Data to Response Headers? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Adding Custom Data to Response Headers?" Watch "Adding Custom Data to Response Headers?" New topic
Author

Adding Custom Data to Response Headers?

Saiprasad Natarajan
Greenhorn

Joined: Oct 27, 2010
Posts: 12

Hi

If i add a custom header to the HttpServletResponse object, like say,



and then do a response.SendRedirect(URL) to some other URL, will i be able to read this header value at that app?

I've tried this with 2 dummy servlets in different apps but doesn't seem to be working. Am i getting something wrong here or am i trying something which is not right?

At the redirected URL, i retrieve the headers using request.getHeader(headerName);

TIA
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

I have tried this sample Program :



I have used JMeter tool to observe the Response Data from the Servlet See the screen shot attached )
What i want to say is , It works the custom response headers will also be added .






[Thumbnail for Post.jpeg]


Save India From Corruption - Anna Hazare.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35443
    
    9
and then do a response.SendRedirect(URL) to some other URL, will i be able to read this header value at that app?

No. The response headers are read by the client and then discarded. (Besides, they're response headers, and thus not part of a request.) You'll need to put any data you want to reach the final destination as URL parameters.

Ravi Kiran Va wrote:...

There's no redirection here, so the example is not relevant.


Android appsImageJ pluginsJava web charts
Saiprasad Natarajan
Greenhorn

Joined: Oct 27, 2010
Posts: 12

Thanks for the reply.

I am passing the data using query parameters but i was just wondering if there is a way to differentiate between a redirect and when someone accesses the app from the address bar directly.


Thanks
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Thanks ulf for the relavant answer . (There should be some clapping Icon on the Icons List )
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Adding Custom Data to Response Headers?
 
Similar Threads
How did we get to the error page?
Accessing custom email headers in bounced back emails
Possible to add new custom header
Help DataTable
Passing HTTP Header!