• 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

JSP based pages get confused when user clicks "Submit" more than once, before data retrieved

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
We have a website of the following form:
Tier 1: Application server ( which communicates with the database ). Communicates with web server via XML transactions, over sockets.
Tier 2: web server ( Tomcat server, mostly JSP pages ). The communication over sockets is localized into one Java class ( which we call ClientSocket ).
Tier 3: web browser

What happens is that if the user clicks "Submit", and then clicks "Submit" again, ClientSocket gets confused. I want to make Tier 3 smart enough to know when Tier 2 is still waiting for data from Tier 1. Right now it is rather simplistic in that it just sets a true/false flag inside the JSP page itself. So it is not particularly accurate, and sometimes the flag gets set to "false" by accident, eventhough it is still being process. Currently, if the flag is true, we popup a message asking them to wait.

I have thought about using AJAX. I have also thought about using the JSF component validation stuff. I am not experienced with either. What is the best way to make the Tier 3 smart enough to know that Tier 2 is still waiting for data from Tier 1? If I can figure that out, I can decide how to handle the situation.

Thanks.

Tony
 
Anthony Baldarelli
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One idea that seems promising is to, on the results page, is to use iFrame to display a "processing" message until the other "iFrame" loads ( assuming results page is the one that communicates with the server ). That seems like an interesting idea based on http://stackoverflow.com/questions/3406335/wait-message-for-slow-jsf-page, but I am having a tough time adapting it. Any ideas ( either using iFrames or not ) would be appreciated. Thanks.
 
Ranch Hand
Posts: 129
Firefox Browser Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Can you try with using JavaScript when you click submit button just disable the button . so that user cant click again until you finish your operation ..
what is the action you have to upon clicking submit button .. do it and redirect to the same page or to any other page when you finish your work ..
in this scenario itself you can use ajax also ... !!

Regards
VIJINDAS
 
Anthony Baldarelli
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. I suppose I could have, but I sort of wanted it to be obvious.

Anyway, this is the method I finally chose:

Created a JSP tag that effectively displays a "Please wait" message over the rest of the page, disabling the "underlying" page so that they cannot click "Search" again. See code below.
<%@ tag body-content="empty" %><%@
attribute name="whereProcessing"%><%

if( whereProcessing == null ) whereProcessing = "";
%>
<style>
div#pleaseWait{
position:absolute;
height:100%;
width:80%;
opacity:0.9;
filter:alpha(opacity:90); /* this is for IE */
z-index:30;
display:none;
background-color: white;
}
h1#pleaseWaitMsg{
width:inherit;
margin: 0 auto;
}
</style>
<div id="pleaseWait" >
<h1 id="pleaseWaitMsg" >Processing <%=whereProcessing%> - please wait</h1>
</div>



Then I created some java scripts to "show" and "hide" this section. Still needs some tweaks, but mostly works. Here is the "lowest level" function:
function showProcessingMsg( show )
{
if( show )
{
document.getElementById('pleaseWait').style.display = 'block';
}
else
{
document.getElementById('pleaseWait').style.display = 'none';
}
}


In one of the other functions ( a no arg function that calls showProcessingMsg( true ) ), I also set the "onunload" event so that when the page unloads, the section is hidden and the page goes back to normal. I had to do this because, in Firefox, it was still showing the message on "Go Back".

If anyone has an concerns for the above approach, please tell me. Now is the time to catch a bad idea, before it goes into production. Thanks for your time.
reply
    Bookmark Topic Watch Topic
  • New Topic