-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Donald,

Glad you got things working.

On 8/25/2011 8:57 PM, Donald Jolley wrote:
> Having gotten this far, my next question is this:  Is there any way
> that I can get this to work within the context of a jsp?

Yes, but I would recommend against it.

JSPs should be used for output with all processing (and, hopefully,
anything that can fail) having already been completed by the time the
JSP runs. Sure, JSP has tag libraries for accessing databases and all
kinds of crazy stuff, but that's not good architecture IMHO.

> I have a catch block to handle the exception.  What I'd like to do
> is to jump (on the occurrence of an exception) from the jsp that
> has the method-throwing exception to a different error-handling
> jsp.  Is there a way that I can do that?

There are try/catch taglibs available, but again I'd recommend against
using them.

> public class Test2 extends HttpServlet { public void
> doGet(HttpServletRequest request, HttpServletResponse response) 
> throws ServletException, IOException { 
> response.setContentType("text/html"); PrintWriter out =
> response.getWriter(); out.println("<html>"); 
> out.println("<head><title>Test 2</title></head>"); 
> out.println("<body>"); out.println("<p>Hello, world!</p>"); if
> (request.getParameter("jump") != null ) {
> 
> request.getRequestDispatcher(request.getParameter("jump")).forward(request,
>
> 
response);
> } out.println("</body>"); out.println("</html>"); } }

This looks like using RequestDispatcher.include() might be more
appropriate. When you use forward(), you should let the other servlet
generate the /entire/ response.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk5XvEcACgkQ9CaO5/Lv0PC7XwCgtddXawbUy3Jeb4gsoOykSsgi
0wsAoLoQz02NaV3Br75UGo2eXNrkTZZH
=XN0a
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to