You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by chris brown <de...@reflexe.fr> on 2001/09/24 13:30:05 UTC

[TC4] Confusion over JspWriter and IOException in compiled JSPs (Tomcat bug...?)

Hello,

In a JSP page, I have a method a bit like this:

void myMethod(Object someParam, JspWriter out)
throws IOException
{
  ...
}

The use of "out" is for some quick debugging.  Anyway, this code works fine
under Tomcat 3.2.3, but porting it over to TC4 final produced the following
compilation errors :

"Class org.apache.jsp.IOException not found in throws"

It would seem that although I'm using standard API classes/interfaces
(JspWriter, IOException), the "import" statements in the generated ".java"
files based on the ".jsp" files are too vague... "java.io.IOException" is
getting mixed up with "org.apache.jsp.IOException".

This may be in turn related to some confusion between the public "JspWriter"
class and some underlying implementation class with the same unqualified
name.

As it happens, I don't need to use JspWriter, as it was only for debugging.
However, this sort of ambiguity could be much more annoying for some other
applications!

Hope this helps!
Chris Brown


Re: [TC4] Confusion over JspWriter and IOException in compiled JSPs

Posted by chris brown <de...@reflexe.fr>.
> > But if I import explicitly java.io.IOException, it might cause
unqualified
> > references to the Tomcat IOException class to become mixed up too !
> I dont think there is a tomcat IOException... the compiler was looking for
> that class because it was compiling a servlet that referenced a class
> IOException - which wasn't imported

You may be right in fact, but I can't verify, as all the debugging info has
since been removed.

If the problem reappears, I'll let you know.  After looking at the code
again though, I suspect you're right.

Thanks!


Re: [TC4] Confusion over JspWriter and IOException in compiled JSPs (Tomcat bug...?)

Posted by Dmitri Colebatch <di...@bigpond.net.au>.
On Mon, 24 Sep 2001, chris brown wrote:

> I imported java.io.* ...
did that fix it?

> 
> But if I import explicitly java.io.IOException, it might cause unqualified
> references to the Tomcat IOException class to become mixed up too !
I dont think there is a tomcat IOException... the compiler was looking for
that class because it was compiling a servlet that referenced a class
IOException - which wasn't imported

> I agree that it's good practice to import each class individually using
> fully-qualified names.  However (IMHO), the Tomcat development team ought to
> have imported any internal implementation classes  explicitly where there's
> a risk of namespace collision with very common classes.
big diff between jsp and code though... 110% in code you should never
(unless you absolutely have to - org.w3c.dom.Document and
org.jdom.Document a good example where you do have to) have package names
in code, they should always be explicit imports...  IMHO (o:

> It would have been better still if the fully-qualified names class names
> were used directly in the code for Tomcat, with no imports whatsoever --
> because if both the internal Tomcat classes and other classes with the same
> names are ALL imported explicitly, there's still as much potential for
> confusion.
the servlet code generated by jasper only imports the servlet and jsp
packages and the jasper packages.... perhaps even the jasper packages
shouldn't be imported, but hey...

I assume though that this fixed it?

cheesr
dim

> Using fully-qualified class names everywhere in application code slows down
> development (more typing) and may reduce readability (ok, you know which
> class is which, but lines of code won't fit easily on screen at the same
> time!).
> 
> -Chris
> 
> ----- Original Message -----
> From: "Dmitri Colebatch" <di...@bigpond.net.au>
> To: <to...@jakarta.apache.org>
> Sent: Monday, September 24, 2001 1:41 PM
> Subject: Re: [TC4] Confusion over JspWriter and IOException in compiled JSPs
> (Tomcat bug...?)
> 
> 
> > you need to import java.io.IOException.... probably in previous versions
> > of tomcat the generated code imported this method, thus masking the fact
> > that you didn't import it.... they now (I guess) dont do this, and so the
> > compiler is looking for IOException in the package of the code, which is
> > org.apache.jsp (default jsp package).
> >
> > in summary  page import="java.io.IOException"  shoudl fix it.
> >
> > cheers
> > dim
> >
> > On Mon, 24 Sep 2001, chris brown wrote:
> >
> > > Hello,
> > >
> > > In a JSP page, I have a method a bit like this:
> > >
> > > void myMethod(Object someParam, JspWriter out)
> > > throws IOException
> > > {
> > >   ...
> > > }
> > >
> > > The use of "out" is for some quick debugging.  Anyway, this code works
> fine
> > > under Tomcat 3.2.3, but porting it over to TC4 final produced the
> following
> > > compilation errors :
> > >
> > > "Class org.apache.jsp.IOException not found in throws"
> > >
> > > It would seem that although I'm using standard API classes/interfaces
> > > (JspWriter, IOException), the "import" statements in the generated
> ".java"
> > > files based on the ".jsp" files are too vague... "java.io.IOException"
> is
> > > getting mixed up with "org.apache.jsp.IOException".
> > >
> > > This may be in turn related to some confusion between the public
> "JspWriter"
> > > class and some underlying implementation class with the same unqualified
> > > name.
> > >
> > > As it happens, I don't need to use JspWriter, as it was only for
> debugging.
> > > However, this sort of ambiguity could be much more annoying for some
> other
> > > applications!
> > >
> > > Hope this helps!
> > > Chris Brown
> > >
> > >
> >
> 
> 


Re: [TC4] Confusion over JspWriter and IOException in compiled JSPs (Tomcat bug...?)

Posted by chris brown <de...@reflexe.fr>.
I imported java.io.* ...

But if I import explicitly java.io.IOException, it might cause unqualified
references to the Tomcat IOException class to become mixed up too !

I agree that it's good practice to import each class individually using
fully-qualified names.  However (IMHO), the Tomcat development team ought to
have imported any internal implementation classes  explicitly where there's
a risk of namespace collision with very common classes.

It would have been better still if the fully-qualified names class names
were used directly in the code for Tomcat, with no imports whatsoever --
because if both the internal Tomcat classes and other classes with the same
names are ALL imported explicitly, there's still as much potential for
confusion.

Using fully-qualified class names everywhere in application code slows down
development (more typing) and may reduce readability (ok, you know which
class is which, but lines of code won't fit easily on screen at the same
time!).

-Chris

----- Original Message -----
From: "Dmitri Colebatch" <di...@bigpond.net.au>
To: <to...@jakarta.apache.org>
Sent: Monday, September 24, 2001 1:41 PM
Subject: Re: [TC4] Confusion over JspWriter and IOException in compiled JSPs
(Tomcat bug...?)


> you need to import java.io.IOException.... probably in previous versions
> of tomcat the generated code imported this method, thus masking the fact
> that you didn't import it.... they now (I guess) dont do this, and so the
> compiler is looking for IOException in the package of the code, which is
> org.apache.jsp (default jsp package).
>
> in summary  page import="java.io.IOException"  shoudl fix it.
>
> cheers
> dim
>
> On Mon, 24 Sep 2001, chris brown wrote:
>
> > Hello,
> >
> > In a JSP page, I have a method a bit like this:
> >
> > void myMethod(Object someParam, JspWriter out)
> > throws IOException
> > {
> >   ...
> > }
> >
> > The use of "out" is for some quick debugging.  Anyway, this code works
fine
> > under Tomcat 3.2.3, but porting it over to TC4 final produced the
following
> > compilation errors :
> >
> > "Class org.apache.jsp.IOException not found in throws"
> >
> > It would seem that although I'm using standard API classes/interfaces
> > (JspWriter, IOException), the "import" statements in the generated
".java"
> > files based on the ".jsp" files are too vague... "java.io.IOException"
is
> > getting mixed up with "org.apache.jsp.IOException".
> >
> > This may be in turn related to some confusion between the public
"JspWriter"
> > class and some underlying implementation class with the same unqualified
> > name.
> >
> > As it happens, I don't need to use JspWriter, as it was only for
debugging.
> > However, this sort of ambiguity could be much more annoying for some
other
> > applications!
> >
> > Hope this helps!
> > Chris Brown
> >
> >
>


Re: [TC4] Confusion over JspWriter and IOException in compiled JSPs (Tomcat bug...?)

Posted by Dmitri Colebatch <di...@bigpond.net.au>.
you need to import java.io.IOException.... probably in previous versions
of tomcat the generated code imported this method, thus masking the fact
that you didn't import it.... they now (I guess) dont do this, and so the
compiler is looking for IOException in the package of the code, which is
org.apache.jsp (default jsp package).

in summary  page import="java.io.IOException"  shoudl fix it.

cheers
dim

On Mon, 24 Sep 2001, chris brown wrote:

> Hello,
> 
> In a JSP page, I have a method a bit like this:
> 
> void myMethod(Object someParam, JspWriter out)
> throws IOException
> {
>   ...
> }
> 
> The use of "out" is for some quick debugging.  Anyway, this code works fine
> under Tomcat 3.2.3, but porting it over to TC4 final produced the following
> compilation errors :
> 
> "Class org.apache.jsp.IOException not found in throws"
> 
> It would seem that although I'm using standard API classes/interfaces
> (JspWriter, IOException), the "import" statements in the generated ".java"
> files based on the ".jsp" files are too vague... "java.io.IOException" is
> getting mixed up with "org.apache.jsp.IOException".
> 
> This may be in turn related to some confusion between the public "JspWriter"
> class and some underlying implementation class with the same unqualified
> name.
> 
> As it happens, I don't need to use JspWriter, as it was only for debugging.
> However, this sort of ambiguity could be much more annoying for some other
> applications!
> 
> Hope this helps!
> Chris Brown
> 
>