• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

session variable problem, please help

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a search page with a "search button", after hit that button I call a servlet. The servlet does some database operation and then puts the search result into a session variable. At the same time to hit the search button, another "search result" page pop-up. The result page should read the session variable, and then display the result.

My problem is: sometimes, the server runs so fast, when I try to read the session variable in result page, it is still null or I just get the old session value.

This problem really drives me crazy. Could some one give a good solution to solve this.

Thanks a lot!!!
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's called a 'race condition' and it's been created at your own choosing. Change things so that the results page doesn't display until after the results have been obtained.
 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
What you can probably do is, After processing the data in the servlet, initiate (i.e. popup) the result.jsp from the servlet.

One way of doing this is... forward the request to intermediate.jsp and in that jsp file say window.open with the necessary parameters. In this way your result.jsp will be called only after the servlet processing is complete.

bye,
Kalai S.
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have it pop-up until you verified the value of the session variable.
 
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bear Bibeault:
That's called a 'race condition' and it's been created at your own choosing. Change things so that the results page doesn't display until after the results have been obtained.



I think this would be the best way to do.

You can probably not make a call to that Results pop-up page until the session variable has been populated with the latest results.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic