• Post Reply Bookmark Topic Watch Topic
  • New Topic

adding custom header  RSS feed

 
Neeraj Vij
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please inform, how can we add custom headers in response and read those custom headers from request ?
 
Neeraj Vij
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even though I have cheked on SSL sites that, referer header is coming. I want to avoid a situation when "Browsers omit the Referer header when they are being used over SSL. {quoted from some site} "

I want to solve the issue if Referer header is removed by the browser.

thanks
Neeraj
 
shivendra tripathi
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knowing that http is stateless I am afraid that you can't do that.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Referer header is often suppressed on the client side, so it's best not to rely on its presence.

Furthermore, any headers set in a response will be not be sent along with any subsequent requests (assuming that we're talking about a regular web browser, not some specialized client).
 
Neeraj Vij
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found some links on google.. which states that it can be done through by overrdding methods of HttpServletResponse

custom class needs to extend HttpServletResponseWrapper and object of extnded class can be passed in filters doChain() method.


for example chain.doFilter(req, responseWrapper);


but still unable to find a concrete example..

please guide.


Also, I would like to learn-- how the referer is suppressed on the client side

thanks,
neeraj.
 
Neeraj Vij
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please refer to following link

filter
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Neeraj Vij wrote:I found some links on google.. which states that it can be done through by overrdding methods of HttpServletResponse

If you think that setting a response header will influence what request headers are used for the next request, then you misunderstand how browsers use HTTP on a very fundamental level.

Also, I would like to learn-- how the referer is suppressed on the client side

That could be done by a browser plugin, or a client-side proxy, and some browsers even have settings for that. In Firefox, go to the "about:config" URL and look for the "network.http.sendRefererHeader" setting.
 
Neeraj Vij
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks ulf ..



then how can we implement a similar functioanlity that is being used with http header 'referer'..

please guide, how can we track the source from where the request was refered if 'referer' header is not reliable.


thanks
neeraj.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't, reliably. But most requests will include that header (because not all that many people will be tech-savvy enough to block it), so any aggregate data obtained from it may still be useful.
 
Neeraj Vij
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!