This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes problem in throwing exceptions ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "problem in throwing exceptions ?" Watch "problem in throwing exceptions ?" New topic
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in throwing exceptions ?
 
Similar Threads
help me to catch ...
c:catch problem ?
Clarification Required
A runtime exception is throws in the catch clause:
Exception: c:catch doubt