Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Adding Custom Data to Response Headers?

 
Saiprasad Natarajan
Greenhorn
Posts: 12
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .




Post.jpeg
[Thumbnail for Post.jpeg]
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Saiprasad Natarajan
Greenhorn
Posts: 12
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks ulf for the relavant answer . (There should be some clapping Icon on the Icons List )
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic