The application is designed to generate HTTP post request to a URL with couple of parameters. The response to this request needs to be displayed in a new browser window. This new window will generate all future request to the application.
I use HttpClient to generate the request to the new URL which has the same context. The problem arises when the post request is generated, a new session is created and the response is displayed. At this point there are 2 jsessions active- the one with which the Http request was generated and the other which was initiated to display the reponse in new window. When I try to use the application in the new window it uses the initial session and hence does not find the application related session attributes which are stored in the session used to display the response. I need to avoid the creation of new session when a new window is opened to display the reponse to Http post request. I use the following String url = "http://localhost:8085/app/Login.do"; HttpClient client = new HttpClient(); client.getState().addCookie(new Cookie("localhost:8085","jsessionid", request.getSession().getId(), "app", null, false)); PostMethod method = new PostMethod( url ); // Configure the form parameters method.addParameter( "encryptedData", encryptedData ); method.addParameter( "HMAC", HMAC); method.addParameter( "jsessionid", request.getSession().getId()); log.info("Open browser"+url); int statusCode; // Execute the POST method try { statusCode = client.executeMethod(method); } catch(IOException e) { statusCode = -1; log.info("IOexception"); } log.info("status code"+statusCode); if( statusCode != -1 ) { String contents = method.getResponseBodyAsString(); response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println(contents); method.releaseConnection(); Regards Sushil
