Hello, I have a JSP page that loads data from database. In this page I have a routine that checks if something was returned from the database. While nothing is returned, a "Please wait, menus are being searched..." message is displays. The problem is that the very first time page is loaded I don't see the message, but then if I perform search again the message appears. The way search is brought up is thru a pop-up window from the main page. Below is part of code from search page. Any suggestions are appreciated.
Also, here is what appears in page source on the first try:
And this is what appears on all of the following trys even if main page is reloaded
The servlet container determines when a new session begins, so after you have created a "wait" attribute for the session, it won't go away until the servlet container decides that the session is over. Usually there is some time out period, or you can always close your browser and restart it...that usually does the trick. Keep in mind that the Refresh header is not part of the official HTTP spec, so no browsers are *required* to support it, even though many do.
Other than these points, I wasn't clear on what your problem is. Are you trying to NOT get the message to display after the first time, or trying to get it to display the first time?
Hi alex, the first time the page is called it will not find the variable "wait" in the session hence the else part will be executed and hence the message dosent get displayed while when u go to the page the second time after searching the attribute is set in the session from the first time around hence the message gets displayed now.
what i suggest is u base the if condition on the result returned from ur search method call instead of some "wait" flag in session something like this maybe u know better.
<% if(session.getAttribute("ResultSet") == null){ %> Please wait, menus are being searched... <% }else{ //display data from database } %> //where the ResultSet may be the actual result from database which can be set in the session...
But isn't this the same as creating some session variable and checking for its existance? Besides, I tried what you suggested with my current set-up and it seems that when I launch search the first time 'please wait...' does appear, but it just keeps looping infinately thru it without ever going into database fetch routine.