• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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: 67637
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.
 
I am Arthur, King of the Britons. And this is a tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic