Say I have code like this:
protected void doPost( HttpServletRequest request, HttpServletResponse
response )
{
...
        String requestString = "GET " + page + " HTTP/1.1";
        String headersString =
                "\r\nHost: " + request.getServerName() +
                        "\r\nCookie: JSESSIONID=" +
request.getSession().getId() +
                        "\r\nContent-Length: 0 " +
                        "\r\nConnection: close" +
                        "\r\n\r\n";

        socket = new Socket( request.getLocalAddr(), request.getLocalPort()
);
        socket.getOutputStream().write( requestString.getBytes( "ISO-8859-1"
) );
        socket.getOutputStream().write( headersString.getBytes( "ISO-8859-1"
) );
        socket.getInputStream().read(); // <----- it hangs here
        socket.close();
...
}

It hangs at reading. I found that it works fine without "Cookie:
JSESSIONID=..." in the header. Is it because there's synchronization
somewhere on session id? Is this kind of socket connections considered to be
evil?

ps sorry if it's very basic
-- 
View this message in context: 
http://www.nabble.com/socket-connection-within-servlet-to-the-same-container-tf2620595.html#a7312711
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to