tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Huseyin Sinecan <>
Subject Re: http header setting problem in servlet
Date Tue, 24 Apr 2007 15:37:54 GMT

Thanks for the answer.. Here is the complete code of doGet method:

    protected void doGet(HttpServletRequest theRequest, HttpServletResponse theResponse) throws
ServletException, IOException {


        theResponse.setHeader("Request Version", "HTTP/1.1");
        theResponse.setHeader("Date", "Wed, 18 Apr 2007 09:24:04 GMT");
        theResponse.setHeader("Server", "Tomcat");
        //theResponse.setHeader("Set-Cookie", "JSESSIONID=FixForBuggyProxy;Version=1;Discard;Path=\"/\"");
// HTTP 1.1
        theResponse.setHeader("pragma", "no-cache"); // HTTP 1.0
        theResponse.setHeader("Cache-Control", "no-cache"); // HTTP 1.1
        theResponse.setHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT"); // a past date
        theResponse.setDateHeader("Last-Modified", (new java.util.Date()).getTime());
        //theResponse.setHeader("Set-Cookie2", "JSESSIONID=ForBuggyCachingProxies;Path=\"/\"");
// HTTP 1.1
        theResponse.setHeader("Connection", "close");


        String aResponse = "";
        try {
            RequestProcessor aRequestProcessor = new RequestProcessor();

            aResponse = aRequestProcessor.processRequest(theRequest);
        } catch (InvalidReqException e) {

            System.out.println("EXCEPTION OCCURED: " + e);
        } //end of try-catch block
        catch (Exception ex) {


        PrintWriter aPrintWriter = theResponse.getWriter();

    } //end of doGet method

I think I am playing with the correct response...
And here is an example communication between the client and my servlet application:
POST /MmpNg/MmpNgServlet?x=y HTTP/1.1 
Cookie: JSESSIONID=FixForBuggyProxy 
User-Agent: OutlookAddin 
Content-Length: 163 
Cache-Control: no-cache 
"data coming from client"
HTTP/1.1 200 OK 
Server: Apache-Coyote/1.1 
Content-Length: 68 
Date: Tue, 24 Apr 2007 17:55:10 GMT 
 "data to be sent to client"

Would you have any comments on this..? Sth is certainly wrong, but I am not able to see it..

Thanks & Regards

Huseyin Sinecan

Hassan Schroeder <> wrote: On 4/24/07, Huseyin Sinecan  wrote:

> I want to set header parameters of http response in my servlet.

Are you sure you're working on the right response object? Perhaps
you can post a simple but complete example that fails...

I just tried the following file as a JSP:
 response.setHeader("HooHaa", "whatever");
 response.setHeader("Cache-Control", "no-cache");
what now?
:: and can see the headers are set (using LiveHTTPHeaders).

Hassan Schroeder ------------------------

To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

Ahhh...imagining that irresistible "new car" smell?
 Check outnew cars at Yahoo! Autos.
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message