aspose file tools*
The moose likes JSP and the fly likes session problem in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "session problem in jsp" Watch "session problem in jsp" New topic
Author

session problem in jsp

Nidhi Nagre
Ranch Hand

Joined: Nov 05, 2007
Posts: 64
i looked up a post across this forum wherefrom i came to know that there is diffrence between JSP and servlet in how the server deploy both.

i mean to say that, when JSP/servlet deployed in server frequently , i am not sure which one of two is served in a new startup of server every time?

or is it just a bitter confusion in my mind?

here it would more descriptive with this issue.

there are two JSP pages say page1.jsp and page2.jsp. suppose in a server startup, few objects has been stored as session attribute and jsp2.jsp has been called using getAppletContext().showDocument() method from within page1.jsp. at this time few objects stored in session are accessed inside page2.jsp.
now in same server startup and another cycle few of objects has been edited and stored in the same session and page2.jsp called again using getAppletContext().showDocument() method from within page1.jsp.

now my question is, for second cycle why the session.getAttribute("object") display old value instead of new one for objects those have been changed?

regards
san
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42281
    
  64
If you call those JSP pages from within an applet, how are you handling transferring the session ID? Both ways supported by the servlet/JSP API (cookies and URL rewriting) rely on the session ID being roundtripped between browser and server. Does the applet implement that? If not, then there is no way for the server to know which user/session is calling the JSP page.


Ping & DNS - my free Android networking tools app
Nidhi Nagre
Ranch Hand

Joined: Nov 05, 2007
Posts: 64
actually the applet which calls page2.jsp using it's getAppletContext().showDocument method, has been contained in page1.jsp. there is also an intermidiate servlet which store the objects in session but it is not part of my problem hence i didn't mention it.

moreover, i am using applet-servlet communication from page1.jsp to make the data available inside servlet.
the overall procedure is,

1) user enter the information in page1.jsp.
2) by applet-servlet communication data is sent to servlet to store in session.this is accomplished while being at page1.jsp because applet-servlet communication occurs in background.
3) once data stored in session, page2.jsp is called from page1.jsp using applet's getAppletContext().showDocument method.

in the first cycle it work fine while in second cycle and same server startup when session's object has been edited using same applet-servlet communication and page2.jsp has been called using same method then session.getAttribute() method doesn't show the new values at page2.jsp.

it seems like session has expired at page2.jsp in second cycle. i still can't figure out the problem. while it is cross checked that data has been edited successfully at servlet side.
[ December 30, 2007: Message edited by: Nidhi Nagre ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42281
    
  64
So what's the answer to my question? Without handling the session ID in the applet the session won't be found the second time around.
Nidhi Nagre
Ranch Hand

Joined: Nov 05, 2007
Posts: 64
would you please be more descriptive, how can i do this?


thanks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42281
    
  64
You could start by studying how session handling currently works in the web app. If you're unsure how either of the two methods I mentioned works, have a look at the servlet specification where this is explained in more detail.

If URL rewriting is used, you can append the session ID to the URL being used in the showDocument call. If cookies are used, you may need to switch to URL rewriting, because I don't think that showDocument sends cookies to the server; I'm not sure about that, though.
Nidhi Nagre
Ranch Hand

Joined: Nov 05, 2007
Posts: 64
but, why in first call of jsp it doesn't need session handling/appending cookies/URL rewriting..etc?
[ December 31, 2007: Message edited by: Nidhi Nagre ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42281
    
  64
Because the session doesn't exist, and is created from scratch.
Nidhi Nagre
Ranch Hand

Joined: Nov 05, 2007
Posts: 64
well, after briefing through relative tutorial i got the points how to handle session during a request made by user using cookies and URL rewriting.

even though afterall,one confusion still blending diffrent cencept.
for instance, when cookies are created and configured to be sent by the brower to that resource only which is specified in cookie.setPath("resource") method. whereas, if the requirement of an application is to roundtrip the cookie among diffrent jsp's and servlet's within the same session,then how the cookies should be configured so that either of the resource can recognize the user in that session?

as the case explained in mine second reply.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: session problem in jsp