Problems with error handling framework in Tomcat 5.5 (includes workaround)
Hi! We have a complex web application with lots of JSPs and a considerable amount of servlets for various purposes. Our app runs in Tomcat 5.5 and among other custom error handling techniques we also used the Servlet API mechanism of placing the following directive in our web.xml: error-page exception-typejava.lang.Throwable/exception-type location/JSP/unhandledJSPError.jsp/location /error-page Due to the complexity of our application, it is unpredictable if the unhandled exception occurs before or after the response has already been committed. One example where the exception definitely occurs after the response has been committed is a class that serves download requests. If the user downloads a big amount of data, pressing the cancel button while waiting for the download is normal and must be dealt with in the server application. (Note that i'm using this only as an example, of course the server-side errors that are caused by cancelled user requests can be safely ignored, but this is a totally different discussion outside the scope of this thread.) So, here's what's happening: - user clicks download link - servlet starts writing (say) 100 MB of data to the response - user grows impatient and clicks cancel - servlet encounters a SocketException or similar because it is unable to write further data - while trying to handling the error situation, tomcat calls the reset() method on the response. This causes an IllegalStateException because the servlet has already written and flushed the response. According to the Servlet API, trying to undo a response in any way *after* already having written physical data to the HTTP client is a no-no, hence the IllegalStateException. In this light, it may or may not be OK to actually call the reset() method as is done now (talking of Tomcat 5.5.12) in StandardHostValve.custom(). [Try googling for StandardHostValve.custom(, the numerous results tell you that this error situation occurs frequently out there...] However, the mechanism of a standard error page is of somewhat meager use for a complex application because, as the scenario above shows, it does only work if the response is clean i.e. has not yet been written to physically. We decided to work around this as follows: - Our JSPs will be augmented with a JavaScript redirect to the error page instead of the web.xml error page directive. - Our Struts Action classes will handle all Throwables by redirecting to the error page - Our servlets will handle all Throwables internally So, effectively, no Throwable ever travels outside of the application. (Note of course that browsers w/o JavaScript will probably see an ugly IllegalStateException error instead of our carefully designed error page. Since our app checks that JavaScript is enabled, this is no problem for us.) We're not 100% sure if our approach was actually intended by the Servlet API gurus, so we'd like to know what others think about this and how this issue is dealt with in other nontrivial apps. The most important (and simple) lesson to learn probably is that if your app once has committed data to the client, then it must find a clean method of saying Oops, sorry, there was a problem *together* with the already written data. Any other ideas / suggestions? - Robert Graf-Waczenski LISTSERV Maestro Core Development Team L-Soft Germany GmbH Knowledge is just a click away: http://www.lsoft.com/optin.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Problem with error-handling
I am using Tomcat5.5, j2sdk1.5 I deliberately created a SQLException to try error page handling but it does not work and i don't know why. I have been trying to solve this problem for hours with no result. I would appreciate it if someone offers to look at my war file for me. I'm desperate please help me. web.xml ?xml version=1.0 encoding=ISO-8859-1? !DOCTYPE web-app PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN http://localhost/dtd/web-app_2_3.dtd; web-app context-param param-namedriverClassName/param-name param-valuecom.mysql.jdbc.Driver/param-value /context-param context-param param-namedbUsername/param-name param-valueuser/param-value /context-param context-param param-namedbPassword/param-name param-valuepassword/param-value /context-param listener listener-class MyListener /listener-class /listener servlet servlet-nameErrorServlet/servlet-name servlet-classchapter04.ErrorServlet/servlet-class /servlet servlet servlet-nameLoginServlet/servlet-name servlet-classchapter04.LoginServlet/servlet-class init-param param-namedburl/param-name param-valuejdbc:mysql://localhost/test/param-value /init-param /servlet servlet-mapping servlet-nameLoginServlet/servlet-name url-pattern/login/url-pattern /servlet-mapping servlet-mapping servlet-nameErrorServlet/servlet-name url-pattern/error/url-pattern /servlet-mapping error-page error-code403/error-code location/html/login.html/location /error-page error-page exception-typejava.sql.SQLException/exception-type location/error/location /error-page /web-app LoginServlet.java (doPost method) public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { String userid = req.getParameter(userid); String password = req.getParameter(password); if (userid != null password != null userid.length() 0 password.length() 0) { ServletConfig config = getServletConfig(); ServletContext context = config.getServletContext(); //context param String driverClassName = context.getInitParameter(driverClassName); String dbUsername = context.getInitParameter(dbUsername); String dbPassword = context.getInitParameter(dbPassword); //config param String dburl = config.getInitParameter(dburl); MySqlDAO dao = new MySqlDAO(); try { dao.init(driverClassName, dburl, dbUsername, dbPassword); } catch (ClassNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); throw new ServletException(ClassNotFoundException, e1); } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); throw new ServletException(SQLException, e1); } try { if(dao.verifyUser(userid, password)) { context.setAttribute(userid, userid); ServletContext ct = getServletContext(); RequestDispatcher rd = ct .getRequestDispatcher(/jsp/welcome.jsp); rd.forward(req, res); } else { res.setStatus(HttpServletResponse.SC_FORBIDDEN); } } catch (SQLException e) {
RE: Problem with error-handling
Hi, This what I did 1. I added below configuration error-page exception-typejava.sql.SQLException/exception-type location/index.html/location /error-page 2. Then added below lines to my doPost() throw new ServletException(SQLException, new SQLException()); It works for me. Could you try to direct your error location to a static page instead of a servlet? Vinod -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Saturday, March 26, 2005 11:21 AM To: tomcat-user@jakarta.apache.org Subject: Problem with error-handling I am using Tomcat5.5, j2sdk1.5 I deliberately created a SQLException to try error page handling but it does not work and i don't know why. I have been trying to solve this problem for hours with no result. I would appreciate it if someone offers to look at my war file for me. I'm desperate please help me. web.xml ?xml version=1.0 encoding=ISO-8859-1? !DOCTYPE web-app PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN http://localhost/dtd/web-app_2_3.dtd; web-app context-param param-namedriverClassName/param-name param-valuecom.mysql.jdbc.Driver/param-value /context-param context-param param-namedbUsername/param-name param-valueuser/param-value /context-param context-param param-namedbPassword/param-name param-valuepassword/param-value /context-param listener listener-class MyListener /listener-class /listener servlet servlet-nameErrorServlet/servlet-name servlet-classchapter04.ErrorServlet/servlet-class /servlet servlet servlet-nameLoginServlet/servlet-name servlet-classchapter04.LoginServlet/servlet-class init-param param-namedburl/param-name param-valuejdbc:mysql://localhost/test/param-value /init-param /servlet servlet-mapping servlet-nameLoginServlet/servlet-name url-pattern/login/url-pattern /servlet-mapping servlet-mapping servlet-nameErrorServlet/servlet-name url-pattern/error/url-pattern /servlet-mapping error-page error-code403/error-code location/html/login.html/location /error-page error-page exception-typejava.sql.SQLException/exception-type location/error/location /error-page /web-app LoginServlet.java (doPost method) public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { String userid = req.getParameter(userid); String password = req.getParameter(password); if (userid != null password != null userid.length() 0 password.length() 0) { ServletConfig config = getServletConfig(); ServletContext context = config.getServletContext(); //context param String driverClassName = context.getInitParameter(driverClassName); String dbUsername = context.getInitParameter(dbUsername); String dbPassword = context.getInitParameter(dbPassword); //config param String dburl = config.getInitParameter(dburl); MySqlDAO dao = new MySqlDAO(); try { dao.init(driverClassName, dburl, dbUsername, dbPassword); } catch (ClassNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); throw new ServletException(ClassNotFoundException, e1); } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); throw new ServletException(SQLException, e1); } try { if(dao.verifyUser(userid, password)) { context.setAttribute(userid, userid); ServletContext ct = getServletContext
RE: Problem with error-handling
yeah it works. But i still cannot understand why my code does not work. Theoretically my code should work right? --- Ramu, Vinod [EMAIL PROTECTED] wrote: Hi, This what I did 1. I added below configuration error-page exception-typejava.sql.SQLException/exception-type location/index.html/location /error-page 2. Then added below lines to my doPost() throw new ServletException(SQLException, new SQLException()); It works for me. Could you try to direct your error location to a static page instead of a servlet? Vinod -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Saturday, March 26, 2005 11:21 AM To: tomcat-user@jakarta.apache.org Subject: Problem with error-handling I am using Tomcat5.5, j2sdk1.5 I deliberately created a SQLException to try error page handling but it does not work and i don't know why. I have been trying to solve this problem for hours with no result. I would appreciate it if someone offers to look at my war file for me. I'm desperate please help me. web.xml ?xml version=1.0 encoding=ISO-8859-1? !DOCTYPE web-app PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN http://localhost/dtd/web-app_2_3.dtd; web-app context-param param-namedriverClassName/param-name param-valuecom.mysql.jdbc.Driver/param-value /context-param context-param param-namedbUsername/param-name param-valueuser/param-value /context-param context-param param-namedbPassword/param-name param-valuepassword/param-value /context-param listener listener-class MyListener /listener-class /listener servlet servlet-nameErrorServlet/servlet-name servlet-classchapter04.ErrorServlet/servlet-class /servlet servlet servlet-nameLoginServlet/servlet-name servlet-classchapter04.LoginServlet/servlet-class init-param param-namedburl/param-name param-valuejdbc:mysql://localhost/test/param-value /init-param /servlet servlet-mapping servlet-nameLoginServlet/servlet-name url-pattern/login/url-pattern /servlet-mapping servlet-mapping servlet-nameErrorServlet/servlet-name url-pattern/error/url-pattern /servlet-mapping error-page error-code403/error-code location/html/login.html/location /error-page error-page exception-typejava.sql.SQLException/exception-type location/error/location /error-page /web-app LoginServlet.java (doPost method) public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { String userid = req.getParameter(userid); String password = req.getParameter(password); if (userid != null password != null userid.length() 0 password.length() 0) { ServletConfig config = getServletConfig(); ServletContext context = config.getServletContext(); //context param String driverClassName = context.getInitParameter(driverClassName); String dbUsername = context.getInitParameter(dbUsername); String dbPassword = context.getInitParameter(dbPassword); //config param String dburl = config.getInitParameter(dburl); MySqlDAO dao = new MySqlDAO(); try { dao.init(driverClassName, dburl, dbUsername, dbPassword); } catch (ClassNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); throw new ServletException(ClassNotFoundException, e1); } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); throw new ServletException(SQLException, e1); } try { if(dao.verifyUser(userid, password
RE: Problem with error-handling
Yeah, I agree with you ...I should and it works To check our understanding this what I did this time. I updated my configuration to servlet-mapping servlet-nameSessionExample/servlet-name url-pattern/servlet/SessionExample/url-pattern /servlet-mapping error-page exception-typejava.sql.SQLException/exception-type location/servlet/SessionExample/location /error-page As you can see now it's redirected to a servlet. Could you try some thing like this 1. try a new servlet, which is very simple. 2. test this servlet by entering it's URL in your browser. 3. if this servlet is working fine then map it's url-pattern to your location XML element under error-page as shown in the above sample. I hope this should work. It worked for me (I tried this on jakarta-tomcat-5.5.4) Vinod -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Saturday, March 26, 2005 8:17 PM To: Tomcat Users List Subject: RE: Problem with error-handling yeah it works. But i still cannot understand why my code does not work. Theoretically my code should work right? --- Ramu, Vinod [EMAIL PROTECTED] wrote: Hi, This what I did 1. I added below configuration error-page exception-typejava.sql.SQLException/exception-type location/index.html/location /error-page 2. Then added below lines to my doPost() throw new ServletException(SQLException, new SQLException()); It works for me. Could you try to direct your error location to a static page instead of a servlet? Vinod -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Saturday, March 26, 2005 11:21 AM To: tomcat-user@jakarta.apache.org Subject: Problem with error-handling I am using Tomcat5.5, j2sdk1.5 I deliberately created a SQLException to try error page handling but it does not work and i don't know why. I have been trying to solve this problem for hours with no result. I would appreciate it if someone offers to look at my war file for me. I'm desperate please help me. web.xml ?xml version=1.0 encoding=ISO-8859-1? !DOCTYPE web-app PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN http://localhost/dtd/web-app_2_3.dtd; web-app context-param param-namedriverClassName/param-name param-valuecom.mysql.jdbc.Driver/param-value /context-param context-param param-namedbUsername/param-name param-valueuser/param-value /context-param context-param param-namedbPassword/param-name param-valuepassword/param-value /context-param listener listener-class MyListener /listener-class /listener servlet servlet-nameErrorServlet/servlet-name servlet-classchapter04.ErrorServlet/servlet-class /servlet servlet servlet-nameLoginServlet/servlet-name servlet-classchapter04.LoginServlet/servlet-class init-param param-namedburl/param-name param-valuejdbc:mysql://localhost/test/param-value /init-param /servlet servlet-mapping servlet-nameLoginServlet/servlet-name url-pattern/login/url-pattern /servlet-mapping servlet-mapping servlet-nameErrorServlet/servlet-name url-pattern/error/url-pattern /servlet-mapping error-page error-code403/error-code location/html/login.html/location /error-page error-page exception-typejava.sql.SQLException/exception-type location/error/location /error-page /web-app LoginServlet.java (doPost method) public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { String userid = req.getParameter(userid); String password = req.getParameter(password); if (userid != null password != null userid.length() 0 password.length() 0) { ServletConfig config = getServletConfig(); ServletContext context = config.getServletContext(); //context param String driverClassName = context.getInitParameter(driverClassName); String dbUsername = context.getInitParameter(dbUsername); String dbPassword = context.getInitParameter(dbPassword); //config param
RE: Problem with error-handling
I found out what is wrong. I should set the response header to OK. Then the error page will display correctly. ErrorServlet: public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { res.setStatus(HttpServletResponse.SC_ACCEPTED); PrintWriter pw = res.getWriter(); pw.write(head); pw.write(title); pw.write(Error Page); pw.write(/title); pw.write(/head); } --- Ramu, Vinod [EMAIL PROTECTED] wrote: Yeah, I agree with you ...I should and it works To check our understanding this what I did this time. I updated my configuration to servlet-mapping servlet-nameSessionExample/servlet-name url-pattern/servlet/SessionExample/url-pattern /servlet-mapping error-page exception-typejava.sql.SQLException/exception-type location/servlet/SessionExample/location /error-page As you can see now it's redirected to a servlet. Could you try some thing like this 1. try a new servlet, which is very simple. 2. test this servlet by entering it's URL in your browser. 3. if this servlet is working fine then map it's url-pattern to your location XML element under error-page as shown in the above sample. I hope this should work. It worked for me (I tried this on jakarta-tomcat-5.5.4) Vinod -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Saturday, March 26, 2005 8:17 PM To: Tomcat Users List Subject: RE: Problem with error-handling yeah it works. But i still cannot understand why my code does not work. Theoretically my code should work right? --- Ramu, Vinod [EMAIL PROTECTED] wrote: Hi, This what I did 1. I added below configuration error-page exception-typejava.sql.SQLException/exception-type location/index.html/location /error-page 2. Then added below lines to my doPost() throw new ServletException(SQLException, new SQLException()); It works for me. Could you try to direct your error location to a static page instead of a servlet? Vinod -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Saturday, March 26, 2005 11:21 AM To: tomcat-user@jakarta.apache.org Subject: Problem with error-handling I am using Tomcat5.5, j2sdk1.5 I deliberately created a SQLException to try error page handling but it does not work and i don't know why. I have been trying to solve this problem for hours with no result. I would appreciate it if someone offers to look at my war file for me. I'm desperate please help me. web.xml ?xml version=1.0 encoding=ISO-8859-1? !DOCTYPE web-app PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN http://localhost/dtd/web-app_2_3.dtd; web-app context-param param-namedriverClassName/param-name param-valuecom.mysql.jdbc.Driver/param-value /context-param context-param param-namedbUsername/param-name param-valueuser/param-value /context-param context-param param-namedbPassword/param-name param-valuepassword/param-value /context-param listener listener-class MyListener /listener-class /listener servlet servlet-nameErrorServlet/servlet-name servlet-classchapter04.ErrorServlet/servlet-class /servlet servlet servlet-nameLoginServlet/servlet-name servlet-classchapter04.LoginServlet/servlet-class init-param param-namedburl/param-name param-valuejdbc:mysql://localhost/test/param-value /init-param /servlet servlet-mapping servlet-nameLoginServlet/servlet-name url-pattern/login/url-pattern /servlet-mapping servlet-mapping servlet-nameErrorServlet/servlet-name url-pattern/error/url-pattern /servlet-mapping error-page error-code403/error-code location/html/login.html/location /error-page error-page exception-typejava.sql.SQLException/exception-type location/error/location /error-page /web-app LoginServlet.java (doPost method) public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { String userid = req.getParameter(userid); String password = req.getParameter(password); if (userid != null password != null userid.length() 0
Change in JSP error handling in Tomcat5.0??
Hi. While testing a JSP error page that was working fine 9 months ago, I found that the page is not now performing its function. Instead of displaying an appropriate error message when the associated JSP receives alphabetic data instead of the integer data that it is expecting, an HTTP 500 message saying that the data manipulation JSP cannot be displayed is generated by the browser. The simple application behaves fine when valid data is entered, and the JSP error page itself can be rendered directly (if a suitable check is made for the implicit object 'exception' being equal to null). Here is the (very ordinary) error page declaration line in the data manipulation JSP: %@ page errorPage=AdderError.jsp % Here is the (equally ordinary) associated line in the JSP error page: %@ page isErrorPage=true % The only changes that have taken place since I last tested these pages are the replacement of Java SDK1.4.2 with SDK1.5.0/5.0 and the replacement of Tomcat 4.1 with Tomcat 5.0. It seems highly unlikely that the change of SDK could have led to this problem, but I suppose that there may be some change to Tomcat (or, more likely, version 2.4 of the servlet API) that has passed me by. Can anybody shed light on the cause of this change in behaviour? Any assistance would be greatly appreciated. Cheers. Jan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
mod_jk error handling question
Environment: Apache 2.0.52 mod_jk 1.2.7-beta-2 Tomcat 5.5.4 I've set up Tomcat with and AJP1.3 Connector to handle requests for web apps from Apache. I'd like to be able to set up an ErrorDocument directive for apache to forward the user to a custom error page when tomcat is unavailable. This page would inform the user that maintenance is being performed on the web app and so on. When I test this, the http status code that gets returned by mod_jk is 500 (internal server error). This seems too generic to me as it encompasses all kinds of other errors that mod_jk could experience. I was thinking that mod_jk should return 503 (service unavailable) instead when tomcat cannot be contacted. I modified apache-2.0/mod_jk.c (line 1858) to return HTTP_SERVICE_UNAVAILABLE instead of HTTP_INTERNAL_SERVICE_ERROR. With this change mod_jk now returns 503 when tomcat cannot be contacted, but I have no idea if this is the right place to make this change. Is there a better way to handle this or is this an acceptable change? I'd like to fix it with an Apache source code change as a last resort if possible. Any insight is appreciated. Regards, Jay - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Request dispatcher error handling behavior
Hello, My application uses a controller servlet to dispatch requests to a view servlet in another web app. Both web applications are deployed in an EAR file running on Jboss-3.2.1-Tomcat-4.1.24. Dispatching code: String view = request.getParameter(view); RequestDisptcher dispatcher = this.getServletContext().getContext(/view).getRequestDispatcher(/servlet + view); If the URL given to the request dispatcher does not exist then the server 404 error page is displayed. I have tried to customize this error page firstly by defining an error page in the web.xml file of the Controller webapp. My custom page is displayed when attempting to visit non existent URLs under the controller context but is not displayed when the request is dispatched to the view context. I then also all updated the view webapp with it's own error pages and tested these in the same manner. Again although the page is displayed when visiting the URL directly it is not displayed when the request is dispatched. Finally I have tried to change the server error page by defining an error page in the server web.xml file by adding: error-page error-code404/error-code location/controller/jsp/404.jsp/location /error-page This did not work at all and the default error pages are still displayed. SRV.8.5 in the servlet 2.3 specification states: If the servlet that is the target of a request dispatcher throws a runtime exception or a checked exception of type ServletException or IOException, it should be propagated to the calling servlet. All other exceptions should be wrapped as ServletExceptions and the root cause of the exception set to the original exception before being propagated. This suggests to me that the error page associated with the calling webapp would be displayed if an error occurs in the target servlet. Is this correct or have I misunderstood: SRV.9.9.2 Error Pages The error page mechanism described does not intervene when errors occur in servlets invoked using the RequestDispatcher. In this way, a servlet using the RequestDispatcher to call another servlet has the opportunity to handle errors generated in the servlet it calls. Any help would be most appreciated. Cheers Hoos. -- Hussein Badakhchani hussein(at)xensia.com t:+44 (0) 7801 816 143 Xensia LLP, London UK www.xensia.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
error handling in servlets vs. JSPs
Hello, I have a peculiar problem with Tomcat 4.0.4. My web.xml contains a bunch of error-page elements pointing at error handlers for various exceptions. When one of these exceptions is invoked in a JSP, everything goes fine but when it happens in a servlet, the standard Tomcat error page is displayed instead. After carefully examining the 2.3 Servlet Specification I don't think Tomcat's supposed to do that. Am I mis-reading the specification or is Tomcat not conforming? Or is there some configuration parameter I haven't found? Any advice appreciated. jh -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
JSP error handling
Hi there, I've a problem with JSP error handling. I tried to make custom error pages with the % page errorPage=... % element. If an error occurs during the execution of my jsp page, the error page is called, but the javax.servlet.error.* attributes do not contain any values. I looked into the Tomcat 4.0 source and found a valve called ErrorDispatcherValve. Has it something to do with jsp error handling? I tried to include the valve with Valve... and with Host errorReportingValve=, but the error page still reports the attributes to be null. I use Tomcat 4.0.4 from the Debian distribution with marginal chances in server.xml. Thanks in advance, Jan -- To unsubscribe, e-mail: mailto:tomcat-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:tomcat-user-help;jakarta.apache.org
Re: JSP error handling
There are two valves used to handle errors. The first one is the ErrorDispatcherValve. This is the valve that will forward the request to the error page if there is a uncaught exception. The second valve is the ErrorReportValve wich is the last valve on the list of valves of a Host and is used to generate a error report in HTML. You don't need to add this valves by hand because they are added by the start method of the StandardHost implementation. If you are using other implementation of the Host interface you must add this valves yourself. The exception of JSP's are stored under the attibute 'javax.servlet.jsp.jspException' of the request. But you must access this value directly using the 'exception' variable already declared on the context of the error page. --- Jan Kunzmann [EMAIL PROTECTED] wrote: Hi there, I've a problem with JSP error handling. I tried to make custom error pages with the % page errorPage=... % element. If an error occurs during the execution of my jsp page, the error page is called, but the javax.servlet.error.* attributes do not contain any values. I looked into the Tomcat 4.0 source and found a valve called ErrorDispatcherValve. Has it something to do with jsp error handling? I tried to include the valve with Valve... and with Host errorReportingValve=, but the error page still reports the attributes to be null. I use Tomcat 4.0.4 from the Debian distribution with marginal chances in server.xml. Thanks in advance, Jan -- To unsubscribe, e-mail: mailto:tomcat-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:tomcat-user-help;jakarta.apache.org __ Do you Yahoo!? HotJobs - Search new jobs daily now http://hotjobs.yahoo.com/ -- To unsubscribe, e-mail: mailto:tomcat-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:tomcat-user-help;jakarta.apache.org
Re: JSP error handling
If the errorPage attribute references another JSP, make sure that page has: %@ page isErrorPage=true % Otherwise, attempting to use the implicit exception object *should* result in an error. I'm guessing that the javax.servlet.error.* request attributes will only get populated if you make use of web.xml error pages. In other words, no errorPage attribute in the page directive but an error-page entry in web.xml for the appropriate exception type. Quoting Ricardo Moral [EMAIL PROTECTED]: There are two valves used to handle errors. The first one is the ErrorDispatcherValve. This is the valve that will forward the request to the error page if there is a uncaught exception. The second valve is the ErrorReportValve wich is the last valve on the list of valves of a Host and is used to generate a error report in HTML. You don't need to add this valves by hand because they are added by the start method of the StandardHost implementation. If you are using other implementation of the Host interface you must add this valves yourself. The exception of JSP's are stored under the attibute 'javax.servlet.jsp.jspException' of the request. But you must access this value directly using the 'exception' variable already declared on the context of the error page. --- Jan Kunzmann [EMAIL PROTECTED] wrote: Hi there, I've a problem with JSP error handling. I tried to make custom error pages with the % page errorPage=... % element. If an error occurs during the execution of my jsp page, the error page is called, but the javax.servlet.error.* attributes do not contain any values. I looked into the Tomcat 4.0 source and found a valve called ErrorDispatcherValve. Has it something to do with jsp error handling? I tried to include the valve with Valve... and with Host errorReportingValve=, but the error page still reports the attributes to be null. I use Tomcat 4.0.4 from the Debian distribution with marginal chances in server.xml. Thanks in advance, Jan -- To unsubscribe, e-mail: mailto:tomcat-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:tomcat-user-help;jakarta.apache.org __ Do you Yahoo!? HotJobs - Search new jobs daily now http://hotjobs.yahoo.com/ -- To unsubscribe, e-mail: mailto:tomcat-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:tomcat-user-help;jakarta.apache.org -- Kris Schneider mailto:kris;dotech.com D.O.Tech http://www.dotech.com/ -- To unsubscribe, e-mail: mailto:tomcat-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:tomcat-user-help;jakarta.apache.org
Error handling in ServletContextListener/investigating tomcat startup errors
Hey, If I have problems in an implementation of ServletContextListener, TC refuses to give me a reason. How can I log the error message? To generate an error, I divided by zero. A more likely (and less avoidable) exception is NamingException (what I expect). [code] public void contextInitialized(ServletContextEvent event) { try{ Database.init(); Mailer.init(); int i = 0; int j = 1/i; } catch (Exception ne){ // doesn't do anything. System.err.println(ne.fillInStackTrace()); //ne.printStackTrace(); } } [/code] Here's the log file: 2002-10-20 03:25:07 [org.apache.catalina.connector.warp.WarpConnector] Error accepting requests java.net.SocketException: Software caused connection abort at java.net.PlainSocketImpl.socketAccept(Native Method) at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:421) at java.net.ServerSocket.implAccept(ServerSocket.java:243) at java.net.ServerSocket.accept(ServerSocket.java:222) at org.apache.catalina.connector.warp.WarpConnector.run(WarpConnector.java:590) at java.lang.Thread.run(Thread.java:496) In general, it is annoying when TC refuses to start. I'd like to have some sort of meaningful message as to why. How can I get a meaningful exception/error msg? = Garrett Needs A Job __ Do you Yahoo!? Y! Web Hosting - Let the expert host your web site http://webhosting.yahoo.com/ -- To unsubscribe, e-mail: mailto:tomcat-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:tomcat-user-help;jakarta.apache.org
BodyContent, including files and error handling
I am trying to include a JSP which generates runtime errors - for now - in another JSP. I would like to know why, c:set var=someVar jsp:include page=/some-page.jsp/ /c:set produces a tomcat error page correctly identifying the error in the included page, but % BodyContent body = pageContext.pushBody(); pageContext.include(/some-page.jsp); pageContext.popBody(); String someVar = body.getString(); % or % BodyContent body = pageContext.pushBody(); % jsp:include page=/some-page.jsp/ % pageContext.popBody(); String someVar = body.getString(); % produce a tomcat error page reporting a BodyContentImpl ClassCastException. It would be useful to know what errors the included page is generating without having to use the JSTL. Thanks, Jack -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Error-Handling
Hi, i need help! i want to handle 404-Errors! If there is a 404-Error, tomcat should show an error-page. I'm using Tomcat 3.3 and i put the following in my web.xml error-page error-code404/error-code location/fehler.mb1/location /error-page but it doesn't work! Can anybody help me? Jens -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
AW: Error-Handling
What error(s) do you get ? Try using fehler.html or fehler.jsp. -Ursprüngliche Nachricht- Von: Jens Thielen [mailto:[EMAIL PROTECTED]] Gesendet: Dienstag, 9. Juli 2002 11:58 An: [EMAIL PROTECTED] Betreff: Error-Handling I'm using Tomcat 3.3 and i put the following in my web.xml error-page error-code404/error-code location/fehler.mb1/location /error-page but it doesn't work! Can anybody help me? -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Error-Handling
Did you check your Server-Log for any errors during parsing the web.xml after you restartet your container? Sometimes I made the experiance that it will not take the web.xml. Then a Server newstart works best. All the tags need to be in a certain order (lock into the servelet spec) Rainer Hi, i need help! i want to handle 404-Errors! If there is a 404-Error, tomcat should show an error-page. I'm using Tomcat 3.3 and i put the following in my web.xml error-page error-code404/error-code location/fehler.mb1/location /error-page but it doesn't work! Can anybody help me? Jens -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
AW: Error-Handling
i used fehler.jsp too, but there is still the tomcat error page 404 Not found request: /wkorb/lala.jsp -Ursprüngliche Nachricht- Von: Ralph Einfeldt [mailto:[EMAIL PROTECTED]] Gesendet am: Dienstag, 9. Juli 2002 12:03 An: Tomcat Users List Betreff: AW: Error-Handling What error(s) do you get ? Try using fehler.html or fehler.jsp. -Ursprüngliche Nachricht- Von: Jens Thielen [mailto:[EMAIL PROTECTED]] Gesendet: Dienstag, 9. Juli 2002 11:58 An: [EMAIL PROTECTED] Betreff: Error-Handling I'm using Tomcat 3.3 and i put the following in my web.xml error-page error-code404/error-code location/fehler.mb1/location /error-page but it doesn't work! Can anybody help me? -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
return codes for error handling
When a jsp, or servlets exceptions are handled by an error page either via jsp errorPage or error-page in web.xml is the response 200OK or 500 ? or something else? Thanks Frank
Error-Handling
Hi, is is possible to show the user an error/info-page while tomcat is starting? I'm using tomcat 3.3 with Apache/1.3.22 (Unix) Jens dmc news Sie wollen wissen wie gut Ihr Multimedia-Dienstleister ist? dmc belegt unter den größten 50 Dienstleistern Platz 3, in der Empfehlbarkeit Platz 2 und im Preis-Leistungs-Verhältnis sogar Platz 1. Alle Rankings unter - http://www.benchpark.de -- jens thielen [ mailto:[EMAIL PROTECTED]] [ http://www.dmc.de] digital media center gmbh marienstrasse 41 d-70178 stuttgart (germany) fon [49].[711].601747-50 fax [49].[711].601747-77 -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
500 Error Handling
Is it possible for Tomcat 3.2.x to redirect to an errors page rather than displaying the raw 500 error in the browser? Thanks Darrell Porter Dilbert: I have become one with my computer. It is a feeling of ecstasy... the blend of logic and emotion. I have reached... Dogbert: Nerdvana
RE: 500 Error Handling
See the servlet specification. Start by looking into the error-page attribute in web.xml - r -Original Message- From: Darrell Porter [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 23, 2001 9:05 PM To: '[EMAIL PROTECTED]' Subject: 500 Error Handling Is it possible for Tomcat 3.2.x to redirect to an errors page rather than displaying the raw 500 error in the browser? Thanks Darrell Porter Dilbert: I have become one with my computer. It is a feeling of ecstasy... the blend of logic and emotion. I have reached... Dogbert: Nerdvana
Error Handling
Is there anyway to show a cutomized page when an internal error occurs, instead of the tomcat´s default? ps. I´m not talking about exception handling... thanks, Francisco [EMAIL PROTECTED]
Re: Error Handling
The errorPage jsp directive? %@ page errorPage="customError.jsp"%> -- Simon Chatfield VP, Software Development Inteflux Inc.