This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Rust Web Development and have Bastian Gruber on-line!
See this thread for details.
Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Adding Custom Data to Response Headers?

 
Greenhorn
Posts: 12
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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]
 
Rancher
Posts: 43027
76
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks ulf for the relavant answer . (There should be some clapping Icon on the Icons List )
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic