Elijah Roberts wrote:

> I have a question regarding the import statements that get inserted into
> the servlet code generated from JSP files. Specifically with Tomcat 4,
> but it is really just a general JSP question. At the top of each
> generated servlet file, Tomcat inserts serveral import statements, such
> as:
>
> import java.io.PrintWriter;
> import java.io.IOException;
> ...
>

>
> In a JSP page that I wrote, I used a PrintWriter object, but forgot to
> import it myself in the JSP file. On my test Tomcat box it compiled and
> worked properly, because of the import statement that was inserted by
> Tomcat when generating the page. When I went to actually deploy it to our
> production box, which runs JRun, it would not compile without my adding
> an import statement to the top of the JSP.
>
> My question is, what does the JSP spec say about this? The goal for JSP
> is to get it to run without modification on any server that supports JSP,
> so which behavior is correct? Should Tomcat not import any packages or
> objects outside of the javax.servlet package, or is there a set of
> packages and classes that should be imported by all JSP compliant
> servers? I'm going to go look through the spec, but I thought I'd ask as
> someone here probably knows the answer.
>

The default import list is defined in the JSP spec.  For JSP 1.2, it's on p. 47:

    java.lang.*
    javax.servlet.*
    javax.servlet.jsp.*
    javax.servlet.http.*

In Tomcat 3.x, a known problem with Jasper was that it generated some additional
non-standard import statements.  It looks like we haven't addressed that problem
yet in Tomcat 4.


>
> Elijah Roberts
> [EMAIL PROTECTED]

Craig McClanahan


Reply via email to