WebSphere Application Server & Liberty

WebSphere Application Server & Liberty

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  com.ibm.ws.webcontainer.httpOnlyCookies creating a new session for every new request

    Posted 07/15/11 05:04 AM
    Hi All,
    I am facing a problem while tring to make a communication between applet and servlet with HttpOlyCookie enabled.

    Communication between applet -servlet work's fine when the HttpOnlyCookie property is disabled.

    However when the property is enabled the communication between the two breaks.

    The problem which is happening is that when the applet send a request the server creates a new session each time due to which a session does not get established between the two.

    WebsphereApplicationServer : 6.1

    Applet Code (ClientSide):


    URL url = new URL(servletURL);


            HttpURLConnection httpConn = (HttpURLConnection)url.openConnection();


            httpConn.setDoInput (true);


            httpConn.setDoOutput (true);


            httpConn.setRequestProperty("Cookie", "JSESSIONID="+sessionId);


            httpConn.setUseCaches (true);


          ObjectInputStream ois= new ObjectInputStream (httpConn.getInputStream ()); //ObjectInputStream object is not getting created and the code throws exception at //this point.


    Object obj=ois.readObject();


     


    ServerSide:


    ServletOutputStream out = null;


    ObjectOutputStream  oos = null;


    Map map=new HashMap();


    map.put("key", "tested");


    out = response.getOutputStream();


    oos = new ObjectOutputStream(out);


               response.setContentType("application/octet-stream");


               oos.writeObject(map);


     


    Exception :


    java.io.StreamCorruptedException: invalid stream header: 0D0A0D0A


     




  • 2.  com.ibm.ws.webcontainer.httpOnlyCookies creating a new session for every new request

    Posted 07/20/11 05:30 PM

    did you specify =* after the property name?


    see


    publib.boulder.ibm.com/infocenter/wasinf...


    You can specify the following values for this property:

    • * - An asterisk value means that all cookies are given the HTTPOnly attribute.

    • A comma delimited list of the specific cookies that are given the HTTPOnly attribute. The HTTPOnly attribute is only given to cookies that are on this list.



    The following examples illustrate how to specify these two settings:


    com.ibm.ws.webcontainer.HTTPOnlyCookies=*
    com.ibm.ws.webcontainer.HTTPOnlyCookies=cookieName1,Account3Cookie,JsessionID

    you also may want to check out the other property for LTPA:
    com.ibm.ws.security.addHttpOnlyAttributeToCookies=true

    hopefully the answer you want is here.

    I am not sure how applets prorcess httpOnly cookies & maybe that is the problem


  • 3.  com.ibm.ws.webcontainer.httpOnlyCookies creating a new session for every new request

    Posted 12/01/11 06:21 PM
    Hello,

    I am running into this exact same problem in regards to having the HTTPOnly setting enabled on WebSphere and having Applets communicating with Servlets. The communications work fine with the settings disabled, but stop working once they are enabled. I have the (*) settings as Mohammad stated. But there is no difference in the results I am having.

    In a little detail on how the applet is doing the communication...

    We are passing the sessionId to the applet via parameters in the HTML tag. Then when the applet loads it gets the parameter. While the applet loads it makes a HttpURLConnection call, setting the httpConn.setRequestProperty("Cookie", "JSESSIONID="+sessionId);. Using debugging we have confirmed the correct session id is being used. The URL it is passing to is a servlet in form of a .do page. We pass other parameters to that page very query string.

    I apologize for bring back an old thread, but this is the only one I have seen with the exact same problem I have, and I was hoping when I scrolled down there was a direct answer.

    Thank you for your help


  • 4.  com.ibm.ws.webcontainer.httpOnlyCookies creating a new session for every new request

    Posted 12/02/11 02:51 PM
    If it helps the application is running on WebSphere 6.1.0.31