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


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

Re: Catching Thrown Exceptions

From Arved Sandstrom <asandstrom3minus1@eastlink.ca>
Newsgroups comp.lang.java.help
Subject Re: Catching Thrown Exceptions
References <6693b355-c89b-4855-b6d3-0ed7e532cc88@c21g2000yqi.googlegroups.com> <a29b4926-7e8e-4753-94f8-7f8da93bcd7a@a15g2000yqf.googlegroups.com> <ji1c14$7fe$1@news.albasani.net> <7a6d6bf2-2622-451f-8347-d4cc6694d6f4@j8g2000yqm.googlegroups.com>
Message-ID <05B1r.8173$vo2.3550@newsfe07.iad> (permalink)
Organization Public Usenet Newsgroup Access
Date 2012-02-23 20:45 -0400

Show all headers | View raw


On 12-02-23 01:20 PM, Davej wrote:
> On Feb 21, 6:14 pm, Lew <no...@lewscanon.com> wrote:
>> "Davej" wrote:
>>>
>>> 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;
>>> }
>>
>> You shouldn't have Java source in a JSP page.
>>
>> Perhaps you are aware that 'exception' is a predefined
>> variable in an error JSP that has value only when there
>> actually is an exception? Or perhaps you mean something
>> different by "compiled" than I do? You send us these
>> code fragments that yield no context. On the face of it
>> I don't know how your code fragment was able to compile
>> successfully.
>>
> 
> From what I have read it is perfectly acceptable to have code in a JSP
> page. It has been said that if there is more HTML than code a JSP is
> the proper thing to use. If there is more code than HTML then a
> servlet is the proper thing to use. Do you disagree with this?
> 
> Yes, I had a syntax error. No I did not know that exception was a
> system variable. No I don't care about documenting the error in this
> tiny example program. And no I am not yet comfortable with JIT
> compiles. I don't know how to force Netbeans to do a complete
> compile.
> 
In addition to everything others have mentioned, which I second, I'll
add a couple of comments about sources and usages.

One, technologies often appear without clear initial guidelines as to
recommended use. Sun produced JSPs partly to compete with PHP and
classic ASP; the first JSP showed up in 1999 just months after the first
production servlet spec. Lots of things were pretty shaky with respect
to web development back in 1999, let's put it that way. Sun just wanted
to get a product out there.

In any case, just because you *could* include Java in JSPs never meant
that you *should*. Within a year or two of JSP first showing up it was
possible, easily, to find any number of web articles that offered best
practices wrt JSPs, including the recommendations that other posters
have made in this thread.

Two, the majority of web pages, magazine articles or books that deal
with most technologies are either mediocre and/or wrong. There is no
expertise required to author a web page, and some of the publishers
(which are well-known for this) just churn out dreck. Unfortunately it's
something of a chicken and egg problem when it comes to figuring out
what sources are garbage: you have to have enough general experience to
develop an eye for good-quality writing, and past that you sort of have
to know something about a subject in order to judge recommendations
about it.

You should get into the habit of referring to official specs where you
can. As early as the JSP 1.2 spec and early JSP coding conventions it
was recommended that JSTL (standard tags), custom tags and backend
servlet pre-processing be used to severely minimize or eliminate the use
of scriptlets...that should tell you something.

AHS

-- 
-- Gaiety is the most outstanding feature of the Soviet Union.
Josef Stalin, November 1935

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