I have a Servlet, which is taking some time to process the request , because of the huge data. I have to show message on the browser to notify the user that the request is in process and have close it once the servlet sends data back to the browser. Thanks
You can use the following header :
<jsp:useBean id="tast" class="FormProcessingBean" scope="session">
Send result after processing
It will keep refreshing the page after 10 secs until your FormProcessingBean
is done. Of course, FormProcessingBean has to process the request in a
separate thread of execution.
Thanks for reply and Can you help me how in servlets ?
Hi, what I showed you using a java bean and not a servlet, try to create a simple java bean with setXXX and getXXX for all the fields in your database, create the connection in the constructor, and start playing with preparedstatment,
Can you be more specific.As i am using jsp pages and at one instance i send request to a remote server and it takes time to get the response and i want to show a wait page till the response is available. A clear answer will be highly helpful.Thanks
Many said answers like Refreshing, threading , etc but nothing is working properly.I will post when I get the answer.
Instead of invoking your servlet directly, serve up a static page that invokes the servlet using a META tag:
<meta HTTP-EQUIV="refresh" content="0; url=/servlet/MyServlet?param1=param1">
The client will see the "Please wait..." page until the servlet returns a response.
New Atlanta Communications
The JSPs in my webapp check to make sure that the session is still valid before doing anything. Also, cookies are disabled so I use URL rewriting with the jsessionid.
For some reason this causes the destination page to behave as though the session has expired.
Let me explain more concretely:
Here is the link to the wait page:
Click here to load a slow page</a>
Here is the vital line from loading.jsp:
<META HTTP-EQUIV="REFRESH" CONTENT="1;URL=<%=response.encodeURL(request.getParameter("url"))%>">
So in this case, the desination url is foo.jsp, which calls code to make sure the session still exists (using the pageContext as a parameter). I definitely have the sessionID in my URL, but somehow the servlet container thinks it no longer has a valid session. I'm confused......
Is there another way? Rewriting the servlet to be threaded is not an option in my case.
Not sure why this worked, I would have thought it was functionally identical to a meta refresh tag. But I got rid of the meta refresh tag and replaced it with this:
This will be my last post on the subject unless I come up with an incontrovertibly final solution. Basically, the previous solution worked on on my test and production systems using Firefox, but failed (as per my first post above) when using IE on the production, but not test system.
Not sure why that is.
I thought of using forward() but of course that won't work if you have already printed something (like "Please Wait") to your output stream.