You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Elijah Roberts <er...@alexandriasc.com> on 2000/11/30 23:39:58 UTC

Import statements in JSP generated servlets

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.

Elijah Roberts
eroberts@alexandriasc.com