You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Dennis Huang <De...@datacom.com.au> on 2000/09/07 03:19:36 UTC
RE: How can I place servlets in a directory different from tomcat
/webapps?
Can we place servlets/jsp outside webapps? What I have learnt is servlets
have to be placed at /webapps/myapps/WEB-INF/classes. Is this correct?
Dennis
-----Original Message-----
From: MBP [mailto:mbp@back-bone.dk]
Sent: Thursday, September 07, 2000 2:17 AM
To: tomcat-user@jakarta.apache.org
Subject: How can I place servlets in a directory different from
tomcat/webapps?
Hi
I know several people has asked about this before, but all the threads seem
to end before a clear answer emerges. At least they never get clear enough
for me to understand.
Problem:
I would like to place my servlets in C:\bb_projekt\byg\servlets
html files, images etc. go in C:\bb_projekt\byg\htdocs
Attempts:
After getting myself confused reading Tomcat's User guide, Tomcat
Minimalistic User Guide, part of Servlet specifications and an uncounted
number of mails in mailing lists, I now know I have to edit server.xml,
httpd.conf, tomcat-apache.conf and possibly web.xml.
In httpd.conf I add a virtual server:
NameVirtualHost 192.168.0.231:80
<VirtualHost 192.168.0.231>
ServerAdmin mbp@bb.dk
DocumentRoot /bb_projekt/byg/htdocs
ServerName mbp.byg.int
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory "C:/bb_projekt/byg/htdocs">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ "C:/bb_projekt/byg/cgi-bin/"
<Directory "C:/bb_projekt/byg/cgi-bin">
AllowOverride None
Options None
</Directory>
ErrorLog logs/byg_error.log
CustomLog logs/byg_access.log common
</VirtualHost>
In Tomcat-apache.conf I copy one of the example mappings and edit it:
### Byg servlets mapping
Alias /byg "C:/bb_projekt/byg"
<Directory "C:/bb_projekt/byg">
Options Indexes FollowSymLinks
</Directory>
ApJServMount /byg/servlets /byg
<Location /byg/servlets/ >
AllowOverride None
deny from all
</Location>
In server.xml I add a new context:
<Context path="/byg" docBase="c:/bb_projekt/byg/servlets" debug="0"
reloadable="true" >
</Context>
In C:\bb_projekt\byg\servlets there is a bygsetupservlet.class
What works:
The virtual host is working fine.
I can run Tomcat HelloWorldExample servlet in both Tomcat and thru Apache
I can run my own servlet thru Apache if I place it in the Tomcat examples
directory
What doesn't work:
Any servlet placed in c:\bb_projekt\byg\servlets
In the error log I keep getting messages like this:
[Wed Sep 06 14:53:13 2000] [error] [client 192.168.0.231] File does not
exist: c:/bb_projekt/byg/servlets/bygsetupservlet
So my question is: am I just stupid, have I missed some obscure detail or is
this really hard to get to work?
Whatever the answer to that is, what can I do to get this thing to work?
TIA
Best regards
Michael
Michael Bjerregaard Pedersen, senior software engineer
------------------------------------------------------
Backbone Digital Systems
Ryesgade 19A
DK-2200 Copenhagen N
Tlf. 35 245 245
Re: How can I place servlets in a directory different from
tomcat/webapps?
Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
"J. Mark Brooks" wrote:
> No without violating the servlet specification.
>
To be more precise, Tomcat lets you put an individual web application directory
anywhere you like. If you put it under $TOMCAT_HOME/webapps the app is installed
for you -- otherwise you have to add an entry in $TOMCAT_HOME/conf/server.xml like
this:
<Context path="/myapp" docBase="/path/to/myapp"/>
or
<Context path="/myapp" docBase="c:\path\to\myapp"/>
where "/path/to/myapp" is the *absolute* pathname to the document base directory
for your app.
Inside this directory, you need a WEB-INF subdirectory with a web.xml file in it,
plus WEB-INF/classes and/or WEB-INF/lib directories for the Java classes and JAR
files (respectively) that make up your application.
Assuming you are running standalone, this app will receive all request URIs that
start with "/myapp" and will process them. There is no mechanism within the
servlet spec to define subdirectories in your web app as being in different places
than under the document base -- the whole idea is that a web app should be self
contained, so that you can install it on any servlet container that supports the
2.2 API.
Craig McClanahan
>
> On Thu, 7 Sep 2000, Dennis Huang wrote:
>
> > Can we place servlets/jsp outside webapps? What I have learnt is servlets
> > have to be placed at /webapps/myapps/WEB-INF/classes. Is this correct?
> >
> > Dennis
> >
> > -----Original Message-----
> > From: MBP [mailto:mbp@back-bone.dk]
> > Sent: Thursday, September 07, 2000 2:17 AM
> > To: tomcat-user@jakarta.apache.org
> > Subject: How can I place servlets in a directory different from
> > tomcat/webapps?
> >
> >
> > Hi
> > I know several people has asked about this before, but all the threads seem
> > to end before a clear answer emerges. At least they never get clear enough
> > for me to understand.
> >
> > Problem:
> > I would like to place my servlets in C:\bb_projekt\byg\servlets
> > html files, images etc. go in C:\bb_projekt\byg\htdocs
> >
> > Attempts:
> > After getting myself confused reading Tomcat's User guide, Tomcat
> > Minimalistic User Guide, part of Servlet specifications and an uncounted
> > number of mails in mailing lists, I now know I have to edit server.xml,
> > httpd.conf, tomcat-apache.conf and possibly web.xml.
> >
> > In httpd.conf I add a virtual server:
> >
> > NameVirtualHost 192.168.0.231:80
> > <VirtualHost 192.168.0.231>
> > ServerAdmin mbp@bb.dk
> > DocumentRoot /bb_projekt/byg/htdocs
> > ServerName mbp.byg.int
> >
> > <Directory />
> > Options FollowSymLinks
> > AllowOverride None
> > </Directory>
> > <Directory "C:/bb_projekt/byg/htdocs">
> > Options Indexes FollowSymLinks MultiViews
> > AllowOverride None
> > Order allow,deny
> > Allow from all
> > </Directory>
> >
> > ScriptAlias /cgi-bin/ "C:/bb_projekt/byg/cgi-bin/"
> >
> > <Directory "C:/bb_projekt/byg/cgi-bin">
> > AllowOverride None
> > Options None
> > </Directory>
> >
> > ErrorLog logs/byg_error.log
> > CustomLog logs/byg_access.log common
> >
> > </VirtualHost>
> >
> >
> > In Tomcat-apache.conf I copy one of the example mappings and edit it:
> >
> > ### Byg servlets mapping
> > Alias /byg "C:/bb_projekt/byg"
> > <Directory "C:/bb_projekt/byg">
> > Options Indexes FollowSymLinks
> > </Directory>
> > ApJServMount /byg/servlets /byg
> > <Location /byg/servlets/ >
> > AllowOverride None
> > deny from all
> > </Location>
> >
> >
> > In server.xml I add a new context:
> >
> > <Context path="/byg" docBase="c:/bb_projekt/byg/servlets" debug="0"
> > reloadable="true" >
> > </Context>
> >
> > In C:\bb_projekt\byg\servlets there is a bygsetupservlet.class
> >
> >
> >
> > What works:
> > The virtual host is working fine.
> > I can run Tomcat HelloWorldExample servlet in both Tomcat and thru Apache
> > I can run my own servlet thru Apache if I place it in the Tomcat examples
> > directory
> >
> >
> > What doesn't work:
> > Any servlet placed in c:\bb_projekt\byg\servlets
> > In the error log I keep getting messages like this:
> > [Wed Sep 06 14:53:13 2000] [error] [client 192.168.0.231] File does not
> > exist: c:/bb_projekt/byg/servlets/bygsetupservlet
> >
> >
> >
> > So my question is: am I just stupid, have I missed some obscure detail or is
> > this really hard to get to work?
> >
> > Whatever the answer to that is, what can I do to get this thing to work?
> >
> > TIA
> >
> > Best regards
> > Michael
> >
> >
> > Michael Bjerregaard Pedersen, senior software engineer
> > ------------------------------------------------------
> > Backbone Digital Systems
> > Ryesgade 19A
> > DK-2200 Copenhagen N
> > Tlf. 35 245 245
> >
>
> --
> ---------------------------------------
> J. Mark Brooks
> Sun Certified Programmer for Java 2
> http://www.uncg.edu/~jmbrook2
--
====================
See you at ApacheCon Europe <http://www.apachecon.com>!
Session VS01 (23-Oct 13h00-17h00): Sun Technical Briefing
Session T06 (24-Oct 14h00-15h00): Migrating Apache JServ
Applications to Tomcat
RE: How can I place servlets in a directory different from tomcat
/webapps?
Posted by "J. Mark Brooks" <jm...@bigfoot.com>.
No without violating the servlet specification.
On Thu, 7 Sep 2000, Dennis Huang wrote:
> Can we place servlets/jsp outside webapps? What I have learnt is servlets
> have to be placed at /webapps/myapps/WEB-INF/classes. Is this correct?
>
> Dennis
>
> -----Original Message-----
> From: MBP [mailto:mbp@back-bone.dk]
> Sent: Thursday, September 07, 2000 2:17 AM
> To: tomcat-user@jakarta.apache.org
> Subject: How can I place servlets in a directory different from
> tomcat/webapps?
>
>
> Hi
> I know several people has asked about this before, but all the threads seem
> to end before a clear answer emerges. At least they never get clear enough
> for me to understand.
>
> Problem:
> I would like to place my servlets in C:\bb_projekt\byg\servlets
> html files, images etc. go in C:\bb_projekt\byg\htdocs
>
> Attempts:
> After getting myself confused reading Tomcat's User guide, Tomcat
> Minimalistic User Guide, part of Servlet specifications and an uncounted
> number of mails in mailing lists, I now know I have to edit server.xml,
> httpd.conf, tomcat-apache.conf and possibly web.xml.
>
> In httpd.conf I add a virtual server:
>
> NameVirtualHost 192.168.0.231:80
> <VirtualHost 192.168.0.231>
> ServerAdmin mbp@bb.dk
> DocumentRoot /bb_projekt/byg/htdocs
> ServerName mbp.byg.int
>
> <Directory />
> Options FollowSymLinks
> AllowOverride None
> </Directory>
> <Directory "C:/bb_projekt/byg/htdocs">
> Options Indexes FollowSymLinks MultiViews
> AllowOverride None
> Order allow,deny
> Allow from all
> </Directory>
>
> ScriptAlias /cgi-bin/ "C:/bb_projekt/byg/cgi-bin/"
>
> <Directory "C:/bb_projekt/byg/cgi-bin">
> AllowOverride None
> Options None
> </Directory>
>
> ErrorLog logs/byg_error.log
> CustomLog logs/byg_access.log common
>
> </VirtualHost>
>
>
> In Tomcat-apache.conf I copy one of the example mappings and edit it:
>
> ### Byg servlets mapping
> Alias /byg "C:/bb_projekt/byg"
> <Directory "C:/bb_projekt/byg">
> Options Indexes FollowSymLinks
> </Directory>
> ApJServMount /byg/servlets /byg
> <Location /byg/servlets/ >
> AllowOverride None
> deny from all
> </Location>
>
>
> In server.xml I add a new context:
>
> <Context path="/byg" docBase="c:/bb_projekt/byg/servlets" debug="0"
> reloadable="true" >
> </Context>
>
> In C:\bb_projekt\byg\servlets there is a bygsetupservlet.class
>
>
>
> What works:
> The virtual host is working fine.
> I can run Tomcat HelloWorldExample servlet in both Tomcat and thru Apache
> I can run my own servlet thru Apache if I place it in the Tomcat examples
> directory
>
>
> What doesn't work:
> Any servlet placed in c:\bb_projekt\byg\servlets
> In the error log I keep getting messages like this:
> [Wed Sep 06 14:53:13 2000] [error] [client 192.168.0.231] File does not
> exist: c:/bb_projekt/byg/servlets/bygsetupservlet
>
>
>
> So my question is: am I just stupid, have I missed some obscure detail or is
> this really hard to get to work?
>
> Whatever the answer to that is, what can I do to get this thing to work?
>
> TIA
>
> Best regards
> Michael
>
>
> Michael Bjerregaard Pedersen, senior software engineer
> ------------------------------------------------------
> Backbone Digital Systems
> Ryesgade 19A
> DK-2200 Copenhagen N
> Tlf. 35 245 245
>
--
---------------------------------------
J. Mark Brooks
Sun Certified Programmer for Java 2
http://www.uncg.edu/~jmbrook2