aspose file tools*
The moose likes Servlets and the fly likes Adding and removing headers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Adding and removing headers" Watch "Adding and removing headers" New topic
Author

Adding and removing headers

mohamed zafer
Ranch Hand

Joined: Nov 03, 2000
Posts: 62
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

Joined: Jun 25, 2001
Posts: 16228
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Adding and removing headers