You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Lu, Spencer" <sl...@spaceworks.com> on 2001/04/18 01:31:24 UTC

Why does servlet need to be in a subdir of WEB-INF/classes?

Hi,

I've noticed that a servlet class invoked by Tomcat must reside in a
subdirectory of <docBase>/WEB-INF/classes.  Ideally I would like to be able
to place my servlet class in a directory that is not under WEB-INF/classes.
Is there any way to do this without changing the Tomcat source and
recompiling it?  If not, does anyone know why the developers coded Tomcat
this way, instead of just loading the servlet from a directory in the
classpath?  Just curious.  Thanks.

Spencer


Re: Why does servlet need to be in a subdir of WEB-INF/classes?

Posted by Stuart Thomson <st...@swtsoft.demon.co.uk>.
Tomcat 3.2 will load servlets from the classpath. I believe that tomcat
3.3 will not do this out of the box, but you will be able to change the
startup scripts to enable it.

"Lu, Spencer" wrote:
> 
> Hi,
> 
> I've noticed that a servlet class invoked by Tomcat must reside in a
> subdirectory of <docBase>/WEB-INF/classes.  Ideally I would like to be able
> to place my servlet class in a directory that is not under WEB-INF/classes.
> Is there any way to do this without changing the Tomcat source and
> recompiling it?  If not, does anyone know why the developers coded Tomcat
> this way, instead of just loading the servlet from a directory in the
> classpath?  Just curious.  Thanks.
> 
> Spencer

Re: Why does servlet need to be in a subdir of WEB-INF/classes?

Posted by Milt Epstein <me...@uiuc.edu>.
On Tue, 17 Apr 2001, Lu, Spencer wrote:

> Hi,
>
> I've noticed that a servlet class invoked by Tomcat must reside in a
> subdirectory of <docBase>/WEB-INF/classes.  Ideally I would like to
> be able to place my servlet class in a directory that is not under
> WEB-INF/classes.  Is there any way to do this without changing the
> Tomcat source and recompiling it?  If not, does anyone know why the
> developers coded Tomcat this way, instead of just loading the
> servlet from a directory in the classpath?  Just curious.  Thanks.

Because that's what the spec says they're supposed to do?

Seriously, if you say more about what you're trying to do and why,
maybe people can give you some better explanations and suggestions.
The WEB-INF/classes et al stuff (in the 2.2 spec) is a change from the
previous, and is generally an improvement.  It allows for bundling web
applications in one spot.  There's also a way to place things in a
"root" context, things that aren't in a particular web application,
but I believe that still involves putting the servlet class in a
WEB-INF/classes directory.

Milt Epstein
Research Programmer
Software/Systems Development Group
Computing and Communications Services Office (CCSO)
University of Illinois at Urbana-Champaign (UIUC)
mepstein@uiuc.edu