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.
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
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>
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>
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..
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.
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.