• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

session problem in jsp

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Nidhi Nagre
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
would you please be more descriptive, how can i do this?


thanks
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because the session doesn't exist, and is created from scratch.
 
Nidhi Nagre
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic