This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet "Please Wait" Page" Watch "Servlet "Please Wait" Page" New topic
Author

Servlet "Please Wait" Page

Nura Horne
Ranch Hand

Joined: Jul 26, 2001
Posts: 40
Hi All,
This question is two fold:
1.
I have a servlet that accesses a database and thus under certain conditions an exception can occur. When such an exception occurs I would like to redirect to display an error page and then terminate the servlet... are there any special techniques for doing this or should I just write appropriate html tags/text to HttpResponse and "return"?
2.
Assuming an exception is not generated a query can take a long time. As such I would like to display a page telling the user the the calculation is in progress that remains visible from the moment the query form is submitted until the calculation is complete and the results are ready to be sent to the client. The query results are actually an SVG file (mime:
image/svg+xml). The structure of the calls through the system are:
HTML query from --> [form data] --> QueryServlet --> Results
Is there some way I can display a working page and then when the QueryServlet is ready to send the results to the client, remove this page and begin sending the results?
Thanks in advance,
Arun
Siva Jagadeesan
Ranch Hand

Joined: Oct 31, 2000
Posts: 160
Hi Arun:
Let me answer your first question.
You could setup Error Element in the web.xml, that will map a Exception or Http error code to a HTML (Or Any dynamic page)
So when there is any SQLException , the entry like this in web.xml
<web-app>


Rgds<p>--Siva Jagadeesan<br /><a href="http://java2simple.blog-city.com" target="_blank" rel="nofollow">http://java2simple.blog-city.com</a><br />Sun Certified Java2 Programmer<br />Sun Certified Web Component Developer<br />BEA Certified Weblogic Server 7 Enterprise Developer
Siva Jagadeesan
Ranch Hand

Joined: Oct 31, 2000
Posts: 160
Sorry I pressed the submit button before I answered your question
<web-app>
....
<error-page>
<exception-type>
java.sql.SQLException
</exception-type>
<location>
sqlerror.html
</location>
</error-page>
...
</web-app>
Asher Tarnopolski
Ranch Hand

Joined: Jul 28, 2001
Posts: 260
regarding the second question ...
you should play with thread and refresh header. take a look on example in this book:
www.coreservlets.com
i don't remeber the chapter number, but the example called "big numbers" or smth like this..


Asher Tarnopolski
SCJP,SCWCD
Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400
For "Please wait" ,alternatively, you can use the <div> element also !! I have used the <div> layer to show the user the desired message and the moment result was ready the new page refreshed the existing page with results.


- Varun
sunitha reghu
Ranch Hand

Joined: Dec 12, 2002
Posts: 937
Originally posted by varun Khanna:
For "Please wait" ,alternatively, you can use the <div> element also !! I have used the <div> layer to show the user the desired message and the moment result was ready the new page refreshed the existing page with results.

Varun,
can u plz explain it
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet "Please Wait" Page
 
Similar Threads
Moving through servlets with grace
How do I make stuff show on a web page?
JSP to Excel - beginner
Using jQuery $.post() - Does it affect request.getRequestDispatcher?
my servlet can't initialize: null