• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Adding and removing headers

 
mohamed zafer
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there,
The request to my servlet, can have no HTTP headers. In this case I should add HTTP headers before sending it to the servlet. Also the response coming from the servlet should be stripped down of the HTTP header's before leaving the server. Heard that filters can be used for this purpose.
Someone please shed more light on how to do it.
Zafer
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's probably not a good idea to be dependent on the absence of HTTP headers either coming or going. They're there for a reason.
If your client is a Java client, you can do the next best thing - contact the server with an HttpURLRequest and simply ignore the headers - which you won't even see.
On the other hand, if you truly need a protocol that is like HTTP but without headers, you should write your servlet using the non-HTTP Servlet base class (which itself serves as the base class for HttpServlet). You'll also have to configure your container to use a non-HTTP conduit, and the details of this you'll need to get from the docs specific to your appserver.
Just as a reminder, you can't use this technique to attempt to wrench the servlet architecture into behaving like a client/server system. As long as it's a servlet, it's still contrained to strict request-response communications whether it uses HTTP or not.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic