I have a scenario that "MyServlet.java" do a "forward(req, res)" to "My.jsp". "MyServlet.java" code throws ServletException, IOExcpetion, plus since "MyServlet.java" calls other database codes which throws SQLException, so I let "MyServlet.java" also throws SQLException. I want to catch ALL of the above exceptions in "My.jsp" page by using <%@ page errorPage="error.jsp" %> The in "error.jsp" page, I use <%= exception.getMessage() %> to display the exception.
Now the question is: 1. Does this work ? 2. Does the <%=exception.getMessage() %> show what type of error it is ? i.e. if it is a SQLException, does it show it is SQL exception in the message content ? Thanks, Ian
Joined: Nov 27, 2001
sorry one correction for my own post, what my "doGet(req, res)" method throws is ServletException, IOException, and my own customized exception (instead of SQLException which is not allowed to be put here).
about the second question i'm sure it will determine run time type of the exception and print appropriate type. this is SCJP question. about the first question, i didn get u. y it will not work? it will thats why u 've errorPage mechanism in the JSP.. regards maulin