| Author |
problem in throwing exceptions ?
|
yamini nadella
Ranch Hand
Joined: Apr 13, 2004
Posts: 257
|
|
(1) Inside JSP if exception comes then what happens? does it throw exception? (2) when I thrown exception in expressions then it only shown the exception name which I thrown and continued execution of rest . <%= new ArithmeticException("error") %> (3) <% throw new ArithmeticException("error"); %> given HTTP Status 500 error. why this difference between JSP Expression and scriptlets (4) <%= 9/0 %> gave message as java.lang.ArithmeticException: / by zero but in case of scriptlets <%out.print(""+9/0); %> caused HTTP status 500. (5) <%= new ArithmeticException("error") %> <%= 9/0 %> </c:catch> ram raja rani (6) <%= new ArithmeticException("error") %> <%= 9/0 %> INSIDE SCRIPT above part of script gave output as java.lang.ArithmeticException: error INSIDE SCRIPT java.lang.ArithmeticException: / by zero why it did not give error message as java.lang.ArithmeticException: error java.lang.ArithmeticException: / by zero INSIDE SCRIPT (7) here i am trying to use JSTL core <c:catch var="variableException"> <%= new ArithmeticException("error") %> </c:catch> ${variableException} in this script I thought exception is caught and stored in variable variableException. but catch did nothing. Regards, Yamini.
|
 |
Adrian Pang
Ranch Hand
Joined: Feb 20, 2004
Posts: 40
|
|
<%= new ArithmeticException("error") %> does not throw the ArithmeticException. You just created a new object of class ArithmeticException, and printed this object. The code will be similar to: out.println(new ArithmeticException("error")); To throw an exception, you must use a scriplet <% throw new ArithmeticException("error")%>
|
SCJP 1.4, SCWCD 1.4, SCBCD 1.3
|
 |
 |
|
|
subject: problem in throwing exceptions ?
|
|
|