Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #1595

Re: Catching Thrown Exceptions

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.mixmin.net!news.albasani.net!.POSTED!not-for-mail
From Lew <noone@lewscanon.com>
Newsgroups comp.lang.java.help
Subject Re: Catching Thrown Exceptions
Date Wed, 22 Feb 2012 08:00:02 -0800
Organization albasani.net
Lines 59
Message-ID <ji33e4$6k4$1@news.albasani.net> (permalink)
References <6693b355-c89b-4855-b6d3-0ed7e532cc88@c21g2000yqi.googlegroups.com> <a29b4926-7e8e-4753-94f8-7f8da93bcd7a@a15g2000yqf.googlegroups.com> <m3ehtnxeii.fsf@despammed.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace news.albasani.net pqQ7V1KsPsA/IfdWygkyK0HAu732ZigWxOMBidCo5NdDMBNaLoHbGsUi2ooFKoAABpEZePOes0o/h/+v0vj9gKphmFKl6Ai/7NQ5AVpJlGapIPel+Mp9Na4GqEwdPMMq
NNTP-Posting-Date Wed, 22 Feb 2012 16:00:04 +0000 (UTC)
Injection-Info news.albasani.net; logging-data="Wfw53o0wA4W5vG20P/ysYEx7TNcYSMcUYRcsSZYdpwd7DVoHITCaf8GQxfK6jOhdVWSZ6okJDrkD4vGY72m7PHZJ5GnZOholuBZizN9790Jr28Kz+W1tnpOqmBvBH88B"; mail-complaints-to="abuse@albasani.net"
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
In-Reply-To <m3ehtnxeii.fsf@despammed.com>
Cancel-Lock sha1:3oeJB2hDLX/yRas67q5iFP2T7bM=
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.help:1595

Show key headers only | View raw


Jukka Lahtinen wrote:
> "Davej" writes:
>> "Davej" wrote:
>>> I figured that if you threw an exception inside a try it would be
>>> caught. No? In my Java program the throw was not caught. In C# this is
>>> the way things work.
>>
>> Ok, I apologize for not including specific details. This is a jsp file
>> and I had the following inside a try block...
>>
>> if ( condition )
>> {
>>     throw exception;
>> }
>
> What the others said, and..
> I can't see variables condition and exception defined anywhere.
> Or a try block.
> Or a catch block.
>
> So, I guess the error must be on line 42. Or line 16514. Or somewhere
> between, before, or after them.

Well, now, to be perfectly fair we do know certain things, even though the OP 
has steadfastly refused to share a code example. We know he has Java code 
inside a JSP. We know that he did *not* declare the variable 'exception'. We 
know from the message

"org.apache.jasper.JasperException: Unable to compile class for JSP:

"An error occurred at line: 59 in the jsp file: /CalcLoan.jsp
exception cannot be resolved to a variable"

that the error is failure to declare 'exception', notwithstanding the OP's 
refusal to believe the message's statement that it is a compilation error.

We know that he has Java source muddled in with the JSP. Yecch! (Shudder.)

Several respondents have pointed out the need for a 'catch' block to go with 
the 'try'. It is time to recommend to the OP that they read both the Java SE 
and Java EE tutorials, and to reiterate the suggestion that he study and 
follow the advice in

http://sscce.org/

For the search-engine-challenged:
<http://www.oracle.com/technetwork/java/javase/documentation/index.html>
<http://www.oracle.com/technetwork/java/index-jsp-135888.html>
<http://www.oracle.com/technetwork/java/javaee/documentation/index.html>
<http://docs.oracle.com/javaee/6/tutorial/doc/>
Actually, scrap that one - they don't describe JSP any longer. For that:
<http://docs.oracle.com/javaee/5/tutorial/doc/bnagx.html>

"Davej" - measure twice, cut once, dude! Do some reading, learn first.

-- 
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg

Back to comp.lang.java.help | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Catching Thrown Exceptions Davej <galt_57@hotmail.com> - 2012-02-20 22:36 -0800
  Re: Catching Thrown Exceptions Lew <noone@lewscanon.com> - 2012-02-20 23:33 -0800
  Re: Catching Thrown Exceptions Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-02-21 07:58 -0500
  Re: Catching Thrown Exceptions Roedy Green <see_website@mindprod.com.invalid> - 2012-02-21 10:12 -0800
  Re: Catching Thrown Exceptions Davej <galt_57@hotmail.com> - 2012-02-21 11:56 -0800
    Re: Catching Thrown Exceptions Lew <noone@lewscanon.com> - 2012-02-21 16:14 -0800
      Re: Catching Thrown Exceptions Davej <galt_57@hotmail.com> - 2012-02-23 09:20 -0800
        Re: Catching Thrown Exceptions markspace <-@.> - 2012-02-23 10:13 -0800
        Re: Catching Thrown Exceptions Lew <noone@lewscanon.com> - 2012-02-23 14:34 -0800
        Re: Catching Thrown Exceptions Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-02-23 14:47 -0800
        Re: Catching Thrown Exceptions Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-02-23 20:45 -0400
    Re: Catching Thrown Exceptions Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2012-02-22 14:02 +0200
      Re: Catching Thrown Exceptions Lew <noone@lewscanon.com> - 2012-02-22 08:00 -0800
  Re: Catching Thrown Exceptions Davej <galt_57@hotmail.com> - 2012-02-21 12:35 -0800
    Re: Catching Thrown Exceptions Lew <noone@lewscanon.com> - 2012-02-21 16:17 -0800

csiph-web