Panayiotis Periorellis wrote:

 > I'm surprised with this email because I 'm running tomcat 4.01 and I
 > have placed my java classes inside
 >
 > Tomcat/jak/server/classes
 >
 > I import them the way you describe and it seems to work alright.

That's because the servler/classes directory is one of the
container-specific directories I mentioned. But this particular
directory is actually intended for classes used by the container
itself, not for application specific classes. Placing your own
classes here means that you may run into other problems due to
details in how Tomcat loads classes differently depending on
where they are located. In fact, according to the Tomcat documentation,
classes in this directory should not be available to an application
at all, so you either have the class somewhere else as well, or
there's a bug in Tomcat 4.0.1. See this document for details:

    <http://jakarta.apache.org/tomcat/tomcat-4.0-doc/class-loader-howto.html>

 > Furthermore there are 2 directories call web-inf
 > One in
 > Tomcat/jak/webapps/root/web-inf
 > And the other in
 >
 > Tomcat/jak/webapps/examples/web-inf


First, please don't write "web-inf". The directory names are case
sensitive and should be in all caps: WEB-INF. Using lower case
letters may result in various "not found" errrors.

The directories you refer to are two separate web applications.
By default, all directories under the Tomcat webapps directory
represent individual "web applications", a concept and structure
defined by the servlet spec. The "ROOT" (again, all caps) application
contains the Tomcat documentation, the "examples" application
contains servlet and JSP examples. Again, they are separate web
applications, which means among other things that they have
separate class loaders (can't use each others classes), separate
application scopes (can't access each others shared resources),
sepatare session scopes, etc. In other words, completely isolated
from each other. Each web application has its own WEB-INF/classes
and WEB-INF/lib directories for the classes they use, as well as
its own WEB-INF/web.xml file for application config info.

For your own application, you should create your own web application
structure under webapps, or *replace* the ROOT application with
your own stuff.

There's way too much to say about web applications to fit
in a mail. I suggest that you read one of the many tutorials
available online, for instance by following the links at the
end of every mail posted to this list. There are also
plenty on books about JSP, for instance that one I wrote:

    <http://TheJSPBook.com/>

You should also read the documentation for the container you
use. For Tomcat 4, the Application Developer's Guide is a good
start:

    <http://jakarta.apache.org/tomcat/tomcat-4.0-doc/appdev/index.html>

Hans

 > -----Original Message-----
 > From: Hans Bergsten [mailto:[EMAIL PROTECTED]]
 > Sent: 27 February 2002 18:26
 > To: [EMAIL PROTECTED]
 > Subject: Re: How to call a user defined method from a JSP
 >
 >
 > [EMAIL PROTECTED] wrote:
 >
 >
 >>The specifics may vary from server to server, but in general you can
 >>you place the class anywhere.  However, your classpath must point to
 >>the directory containing the code.
 >>
 >
 >
 > This is not correct. All JSP 1.0 (and later) compliant servers look for
 > class files in two very well defined places: the WEB-INF/classes and the
 > WEB-INF/lib directories for the application. The first is for class
 > files and the second for class files packaged in JAR files. In addition,
 > some containers let you place class files and JAR files in
 > container-specific directories, but the two WEB-INF dirctories are
 > *always* used and should be your first choice.
 >
 >
 >>Also, remember to import your class in your
 >>JSP.
 >><%@ page import="DBConnection" %>
 >>
 >
 >
 > This is true, and the reason for why you need to import a class that is
 > not declared to be in a package (i.e. that is part of the unnamed
 > default package) is described in more detail here:
 >
 >    <http://java.oreilly.com/news/jsptips_1100.html>
 >
 > Hans
--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com
JavaServer Pages        http://TheJSPBook.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to