Re: Session Management Within Webapp 2 (jsessionid)s
I updated my processor and added the proper logic that Martin showed yesterday. And what I am seeing is as follows: 1) When the user clicks the site, I can watch the logs and it shows that the session.isNew() and so it redirects to index.jsp. 2) At that point the screen is showing, so the user clicks a link (non html style href) to go view a page. 3) When that page is submitted, I can see by the log, that it calls the ExtendedProcessor and once again, realizes that the session.isNew() and it once again calls the index.jsp page. 4) After that any link the user clicks works, but if you can see the pattern, the user must click two times before the session is established. I would like to have a better handle on why this occurs, or if there is a way I can ensure that this does not happen. It is ugly when the user has to click twice, to get rolling. Thanks for any advice. On 10/24/05, Martin Gainty [EMAIL PROTECTED] wrote: Dumb Question but I have to ask First from the doc for the method public boolean isNew()Returns true if the client does not yet know about the session or if the client chooses not to join the session. For example, if the server used only cookie-based sessions, and the client had disabled the use of cookies, then a session would be new on each request. Returns: true if the server has created a session, but the client has not yet joined Throws: IllegalStateException - if this method is called on an already invalidated session protected boolean processPreProcess(request, response) { protected boolean continuedProcessing = true; try { if (request.getSession()==null)||(request.getSession().isNew() ) { continueProcessing = false; response.sendredirect (/login.jsp); } //end if } //end try catch(IllegalStateException ill) { out.println(IllegalStateException has been thrown the exception is +ill.getMessage()); } return continueProcessing; } //end method a)are you checking to ensure the getSession is NOT NULL before the isNew test ? b)In this scenario is the session is null or session isNew then the method returns false are your returning true/false? c)are you catching the IllegalStateException ??? Anyone else ? M- - Original Message - From: Jim Reynolds [EMAIL PROTECTED] To: user@struts.apache.org Sent: Monday, October 24, 2005 10:57 AM Subject: Session Management Within Webapp 2 (jsessionid)s I have a project which I am working on. It does not have any type of form login. It is just a merchant-type site. When client hits the URL, the index.jsp calls a forward like so: logic:forward name=welcome / This of course sends the request to the struts-config.do. I extended the RequestProcessor to set up some session type beans that control the site. I only create the beans if the session.isNew() returns true. In the RequestProcessor, I can see the beans being created and set into the session. Finally the request is forward to a .jsp page from the original welcome.do call. On the jsp page, I have some tags, with links. Since I am using tags, I just used some normal html style links. Not html:link calls. When a user requests hits a link, and calls another xxx.do, the request goes back to the RequestProcessor, and it thinks the session.isNew(), and I end up creating all the session beans again. After that it works as it should, but I end up with 2 (jsessionid) cookies being created for each user? I am seeking advice, as to why this occured, and if this is normal behavior, or not-normal behavior. Upon researching the topic over the weekend, I was unable to find any threads, about this. Am I doing something wrong, or possibly a logic-flaw somewhere. Thanks, user@struts.apache.org - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Session Management Within Webapp 2 (jsessionid)s
I have a project which I am working on. It does not have any type of form login. It is just a merchant-type site. When client hits the URL, the index.jsp calls a forward like so: logic:forward name=welcome / This of course sends the request to the struts-config.do. I extended the RequestProcessor to set up some session type beans that control the site. I only create the beans if the session.isNew() returns true. In the RequestProcessor, I can see the beans being created and set into the session. Finally the request is forward to a .jsp page from the original welcome.do call. On the jsp page, I have some tags, with links. Since I am using tags, I just used some normal html style links. Not html:link calls. When a user requests hits a link, and calls another xxx.do, the request goes back to the RequestProcessor, and it thinks the session.isNew(), and I end up creating all the session beans again. After that it works as it should, but I end up with 2 (jsessionid) cookies being created for each user? I am seeking advice, as to why this occured, and if this is normal behavior, or not-normal behavior. Upon researching the topic over the weekend, I was unable to find any threads, about this. Am I doing something wrong, or possibly a logic-flaw somewhere. Thanks, user@struts.apache.org
Re: Session Management Within Webapp 2 (jsessionid)s
Dumb Question but I have to ask First from the doc for the method public boolean isNew()Returns true if the client does not yet know about the session or if the client chooses not to join the session. For example, if the server used only cookie-based sessions, and the client had disabled the use of cookies, then a session would be new on each request. Returns: true if the server has created a session, but the client has not yet joined Throws: IllegalStateException - if this method is called on an already invalidated session protected boolean processPreProcess(request, response) { protected boolean continuedProcessing = true; try { if (request.getSession()==null)||(request.getSession().isNew() ) { continueProcessing = false; response.sendredirect(/login.jsp); } //end if } //end try catch(IllegalStateException ill) { out.println(IllegalStateException has been thrown the exception is +ill.getMessage()); } return continueProcessing; } //end method a)are you checking to ensure the getSession is NOT NULL before the isNew test ? b)In this scenario is the session is null or session isNew then the method returns false are your returning true/false? c)are you catching the IllegalStateException ??? Anyone else ? M- - Original Message - From: Jim Reynolds [EMAIL PROTECTED] To: user@struts.apache.org Sent: Monday, October 24, 2005 10:57 AM Subject: Session Management Within Webapp 2 (jsessionid)s I have a project which I am working on. It does not have any type of form login. It is just a merchant-type site. When client hits the URL, the index.jsp calls a forward like so: logic:forward name=welcome / This of course sends the request to the struts-config.do. I extended the RequestProcessor to set up some session type beans that control the site. I only create the beans if the session.isNew() returns true. In the RequestProcessor, I can see the beans being created and set into the session. Finally the request is forward to a .jsp page from the original welcome.do call. On the jsp page, I have some tags, with links. Since I am using tags, I just used some normal html style links. Not html:link calls. When a user requests hits a link, and calls another xxx.do, the request goes back to the RequestProcessor, and it thinks the session.isNew(), and I end up creating all the session beans again. After that it works as it should, but I end up with 2 (jsessionid) cookies being created for each user? I am seeking advice, as to why this occured, and if this is normal behavior, or not-normal behavior. Upon researching the topic over the weekend, I was unable to find any threads, about this. Am I doing something wrong, or possibly a logic-flaw somewhere. Thanks, user@struts.apache.org - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]