• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP session issue

 
PNS Subramanian
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Encounter the following scenario in my web application.

Page1.jsp downloads a htm file(having a certain id value which is placed in session),as a stream of bytes - as this file is downloaded, a request is sent to the server to download an image file.When the image file downloads, the queryString for the image file is parsed to obtain a certain id value. If the previously stored id in session and the id obtained from queryString are the same, the image is displayed.

This works okay for around 90% of the cases, however there are instances where in the id value placed in session turns out to be null, resulting in no image being displayed. From the log files, we do infer that the id value is placed in session, however, when we try retrieving it from session - a null is what is obtained.

Would appreciate if anyone could explain the abnormal behaviour.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the user left their browser sitting idle for more than 30 minutes (or whatever your session timeout is) then came back and started trying to browse your app, this would happen.
 
PNS Subramanian
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This scenario occurs only for around 2-5% of the total number of cases mostly when the user logs in to the application.
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could it be a timing issue? Are you putting the value into the session in your JSP page?
 
PNS Subramanian
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes James.
The value is put in session in page1.jsp and retrieved in the second page, which itself is a request from page1.jsp. The second page does a validation with this value from session as well.This works for 95% plus cases.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you really experiencing timeout in 5% cases? As Ben and James already asked you.

Or

You are sure that timeout isn't the case?
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might try adding a session listener and log (with timestamps) whenever the values in the session are changing. Then, I would also log whenever you receive the request for the image. See if the value is being put into the session after you receive the request for the image.
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, are you using a JSP page to generate the image data?
 
PNS Subramanian
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firstly, thanks for all the responses - though the solution is still not in sight.
1)
"Are you really experiencing timeout in 5% cases? As Ben and James already asked you." - I experience this scenario in less than 5% of the cases.

2)
"You are sure that timeout isn't the case?" - strongly feel timeout isnt the case since it mostly occurs as soon as the user logs in.

3)
"I would also log whenever you receive the request for
the image. See if the value is being put into the session after you receive the request for the image." - the image request is when a bytestream is read. The value is put in session and the same is logged after placing in session.

4)
"By the way, are you using a JSP page to generate the image data? " - No.A pre-generated htm and image file are retrieved as byte streams. The request for retrieval of image inturn is triggered from the htm file that is obtained above(as byte stream).

5)
"You might try adding a session listener.." - this is something which i can do to track when exactly the change occurs
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd say try the session listener so you get an idea of exactly what (and when) is going on. I would imagine that should help you a lot in finding an answer to this perplexing problem.

I don't think it's a timeout issue, either. I said I think it's a timing issue (like a race condition). What I'm thinking is happening is that the browser is getting the <img> tag and requesting the image data in another thread before you get a chance to put your "id" in the session.
 
PNS Subramanian
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried placing the data in a bean which implements HttpSessionBindingListener. Although the bean doesnt get removed from session, (no call to valueUnbound()), the value that i place in session turns out to be null.

One more point which i failed to mention in this regard -
When the htm file being downloaded as a bytestream fails, the response is reset. And the process is tried again - does response resetting have anything to do with changing of session attribute ?
 
PNS Subramanian
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what i do

[ May 09, 2005: Message edited by: PNS Subramanian ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!