You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@jakarta.apache.org by "David M. Karr" <dk...@tcsi.com> on 2000/08/24 22:44:53 UTC

Tomcat: Options for installing HTML "close" to classes?

I have Apache & Tomcat running on my NT workstation. I put a servlet
class into "$TOMCAT_HOME/webapps/ROOT/WEB-INF/classes".  I'm able to
execute it fine from the container.

I also have an HTML file that tries to reference that servlet.  I was
able to put the HTML file into the "$APACHE_HOME/htdocs" directory,
but that seems sort of "far away" from the servlet class.  I can't
figure out where, if at all, the HTML file can go into the
$TOMCAT_HOME/webapps hierarchy so it will work.  Is it
feasible/practical to do this?

I believe that building a WAR file would probably work, but I'm trying
to start simple.

-- 
===============================================================================
David M. Karr     ; dkarr@tcsi.com  ; w:(425)487-8312 ; TCSI & Best Consulting
Software Engineer ; Unix/Java/C++/X ; BrainBench CJ12P (#12004)


Re: Tomcat: Options for installing HTML "close" to classes?

Posted by "David M. Karr" <dk...@tcsi.com>.
>>>>> "Rob" == Rob S <rs...@home.com> writes:
  >> >> DocumentRoot "d:/apache/htdocs"
  >> 
  >> Ah, so all the files are in the same place, but apache serves the html
  >> files, and tomcat serves everything else.

  Rob> Well, to be more specific, Apache serves !(servlets and JSPs) =)

  >> The last line of my httpd.conf is the include of the
  >> "tomcat-apache.conf" file, which I enclose here:

  Rob> k-o...

  >> AddType test/jsp .jsp

  Rob> This should be text/jsp.  Are you using Tomcat 3.1?  You'll want to use
  Rob> 3.2b2.

  >> ApJServMount /servlet /ROOT

  Rob> This is really the only one that pertains to your setup (and that
  Rob> DocumentRoot we talked about before).  That's really all you need.  You
  Rob> should have some <Directory> and <Location> directives to protect the files
  Rob> and indices, but to just "get it running" that's all you need.

  >> I'm digging everything I can find :)

  Rob> Ok cool ;)  What's the status now?

It's working fine now (although I haven't tried any jsp pages yet).
I store the files in the same place, but Apache gets !(servlet|jsp)
and tomcat gets everything else.  I'm currently using 3.1, but I'll
upgrade to 3.2bx in a little while.  I imagine that "test/jsp" thing
would probably cause a problem...

-- 
===============================================================================
David M. Karr     ; dkarr@tcsi.com  ; w:(425)487-8312 ; TCSI & Best Consulting
Software Engineer ; Unix/Java/C++/X ; BrainBench CJ12P (#12004)


RE: Tomcat: Options for installing HTML "close" to classes?

Posted by "Rob S." <rs...@home.com>.
>   >> DocumentRoot "d:/apache/htdocs"
>
> Ah, so all the files are in the same place, but apache serves the html
> files, and tomcat serves everything else.

Well, to be more specific, Apache serves !(servlets and JSPs) =)

> The last line of my httpd.conf is the include of the
> "tomcat-apache.conf" file, which I enclose here:

k-o...

> AddType test/jsp .jsp

This should be text/jsp.  Are you using Tomcat 3.1?  You'll want to use
3.2b2.

> ApJServMount /servlet /ROOT

This is really the only one that pertains to your setup (and that
DocumentRoot we talked about before).  That's really all you need.  You
should have some <Directory> and <Location> directives to protect the files
and indices, but to just "get it running" that's all you need.

> I'm digging everything I can find :)

Ok cool ;)  What's the status now?

- r


Re: Tomcat: Options for installing HTML "close" to classes?

Posted by "David M. Karr" <dk...@tcsi.com>.
>>>>> "Rob" == Rob S <rs...@home.com> writes:
  Rob> Hi David,

  >> Well, for a first example, just as I said, as
  >> "http://<hostname>/<htmlfile>".
  >> 
  >> However, after sleeping on this, I was thinking I was misguided in my
  >> approach, and now I'm not sure anymore.  After I left work last night,
  >> I seemed to remember that the point of running BOTH apache and tomcat
  >> was to have apache serve HTML files, and tomcat to handle servlets and
  >> jsp.  If both of them are running, does it make sense to put HTML
  >> files into tomcat/webapps, and will it even work?  Perhaps it makes
  >> more sense just to run tomcat standalone?

  Rob> Well, I see here you have Tomcat still setup as an HTTP server, re:

  >> <Connector
  >> className="org.apache.tomcat.service.SimpleTcpConnector">
  >> <Parameter name="handler"
  >> value="org.apache.tomcat.service.http.HttpConnectionHandler"/>
  >> <Parameter name="port" value="8080"/>
  >> </Connector>

  Rob> You'll want to comment it out (surround it with <!-- ... -->) since Apache
  Rob> will be serving your static files.

  Rob> This is the context in question.

  >> <Context path="" docBase="webapps/ROOT" debug="9"
  >> reloadable="true" >
  >> </Context>

  >> DocumentRoot "d:/apache/htdocs"

Ah, so all the files are in the same place, but apache serves the html
files, and tomcat serves everything else.  Ok.  I was trying to find
documentation on the "Connector" tag, and I didn't see anything.  This
helps.

  Rob> Should be d:/path/to/tomcat/webapps/ROOT.  So that Apache will serve your
  Rob> static files.  You have no JServ or Jk setup in your httpd.conf, which are
  Rob> entirely necessary to get the two to cooperate.

The last line of my httpd.conf is the include of the
"tomcat-apache.conf" file, which I enclose here:

------------------------
LoadModule jserv_module modules/ApacheModuleJServ.dll
ApJServManual on
ApJServDefaultProtocol ajpv12
ApJServSecretKey DISABLED
ApJServMountCopy on
ApJServLogLevel notice
ApJServDefaultPort 8007
AddType test/jsp .jsp
AddHandler jserv-servlet .jsp
Alias /examples D:\jakarta-tomcat\webapps\examples
<Directory "D:\jakarta-tomcat\webapps\examples">
    Options Indexes FollowSymLinks
</Directory>
ApJServMount /examples/servlet /examples
<Location /examples/WEB-INF/ >
    AllowOverride None
    deny from all
</Location>
Alias /test D:\jakarta-tomcat\webapps\test
<Directory "D:\jakarta-tomcat\webapps\test">
    Options Indexes FollowSymLinks
</Directory>
ApJServMount /test/servlet /test
<Location /test/WEB-INF/ >
    AllowOverride None
    deny from all
</Location>
ApJServMount /servlet /ROOT
------------------------

  Rob> I *highly* suggest taking a look at this since your problems and questions
  Rob> are indicative of someone who isn't fully digging all thing Tomcat and
  Rob> Apache =)  It's not very long.

  Rob> Check it:

  Rob> http://fuzz.cx/~rslifka/tomcat-apache-howto.html

I'm digging everything I can find :) .  I hadn't seen this document
before.  It looks apropos.

-- 
===============================================================================
David M. Karr     ; dkarr@tcsi.com  ; w:(425)487-8312 ; TCSI & Best Consulting
Software Engineer ; Unix/Java/C++/X ; BrainBench CJ12P (#12004)


RE: Tomcat: Options for installing HTML "close" to classes?

Posted by "Rob S." <rs...@home.com>.
Hi David,

> Well, for a first example, just as I said, as
> "http://<hostname>/<htmlfile>".
>
> However, after sleeping on this, I was thinking I was misguided in my
> approach, and now I'm not sure anymore.  After I left work last night,
> I seemed to remember that the point of running BOTH apache and tomcat
> was to have apache serve HTML files, and tomcat to handle servlets and
> jsp.  If both of them are running, does it make sense to put HTML
> files into tomcat/webapps, and will it even work?  Perhaps it makes
> more sense just to run tomcat standalone?

Well, I see here you have Tomcat still setup as an HTTP server, re:

>         <Connector
> className="org.apache.tomcat.service.SimpleTcpConnector">
>             <Parameter name="handler"
> value="org.apache.tomcat.service.http.HttpConnectionHandler"/>
>             <Parameter name="port" value="8080"/>
>         </Connector>

You'll want to comment it out (surround it with <!-- ... -->) since Apache
will be serving your static files.

This is the context in question.

>         <Context path="" docBase="webapps/ROOT" debug="9"
> reloadable="true" >
>         </Context>

> DocumentRoot "d:/apache/htdocs"

Should be d:/path/to/tomcat/webapps/ROOT.  So that Apache will serve your
static files.  You have no JServ or Jk setup in your httpd.conf, which are
entirely necessary to get the two to cooperate.

I *highly* suggest taking a look at this since your problems and questions
are indicative of someone who isn't fully digging all thing Tomcat and
Apache =)  It's not very long.

Check it:

http://fuzz.cx/~rslifka/tomcat-apache-howto.html

- r


Re: Tomcat: Options for installing HTML "close" to classes?

Posted by "David M. Karr" <dk...@tcsi.com>.
>>>>> "Rob" == Rob S <rs...@home.com> writes:
  >> Ok, and how exactly do you specify a URL to reference that?  I would
  >> have guessed "http://localhost/<file>", but that doesn't work.  From
  >> the logs, it doesn't appear as if Tomcat is even getting the request
  >> for the file.  It is handled (and failed) solely by Apache.

  Rob> That all depends on your Apache/Tomcat setup.  Could you paste the pertinent
  Rob> section(s) of your server.xml and httpd.conf?

  Rob> How would you like it to be accessed?

Well, for a first example, just as I said, as
"http://<hostname>/<htmlfile>".

However, after sleeping on this, I was thinking I was misguided in my
approach, and now I'm not sure anymore.  After I left work last night,
I seemed to remember that the point of running BOTH apache and tomcat
was to have apache serve HTML files, and tomcat to handle servlets and
jsp.  If both of them are running, does it make sense to put HTML
files into tomcat/webapps, and will it even work?  Perhaps it makes
more sense just to run tomcat standalone?

In any case, I'll include my "server.xml" here, and the
uncommented/nonblank lines of "httpd.conf" (since I don't know what
the "pertinent" sections would be exactly).

server.xml:
------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>

<Server>
    <!-- Debug low-level events in XmlMapper startup -->
    <xmlmapper:debug level="9" />

    <!-- This is quite flexible; we can either have a log file per
         module in Tomcat (example: ContextManager) or we can have
         one for Servlets and one for Jasper, or we can just have
	 one tomcat.log for both Servlet and Jasper.

	 If you omit "path" there, then stderr should be used.

	 verbosityLevel values can be: 
	    FATAL
	    ERROR
	    WARNING 
            INFORMATION
            DEBUG
         -->

    <Logger name="tc_log" 
            path="logs/tomcat.log"
            customOutput="yes" />

    <Logger name="servlet_log" 
            path="logs/servlet.log"
            customOutput="yes" />

    <Logger name="JASPER_LOG" 
	    path="logs/jasper.log"
            verbosityLevel = "INFORMATION" />

    <!-- Add "home" attribute if you want tomcat to be based on a different directory
         "home" is used to create work and to read webapps, but not for libs or CLASSPATH.
         Note that TOMCAT_HOME is where tomcat is installed, while ContextManager home is the
         base directory for contexts, webapps/ and work/
      -->
    <ContextManager debug="9" workDir="work" >
        <!-- ContextInterceptor className="org.apache.tomcat.context.LogEvents" / -->
        <ContextInterceptor className="org.apache.tomcat.context.AutoSetup" />
        <ContextInterceptor className="org.apache.tomcat.context.DefaultCMSetter" />
        <ContextInterceptor className="org.apache.tomcat.context.WorkDirInterceptor" />
        <ContextInterceptor className="org.apache.tomcat.context.WebXmlReader" />
        <ContextInterceptor className="org.apache.tomcat.context.LoadOnStartupInterceptor" />
        <!-- Request processing -->
        <RequestInterceptor className="org.apache.tomcat.request.SimpleMapper" debug="9" />
        <RequestInterceptor className="org.apache.tomcat.request.SessionInterceptor" />
        <RequestInterceptor className="org.apache.tomcat.request.SecurityCheck" />
        <RequestInterceptor className="org.apache.tomcat.request.FixHeaders" />

        <Connector className="org.apache.tomcat.service.SimpleTcpConnector">
            <Parameter name="handler" value="org.apache.tomcat.service.http.HttpConnectionHandler"/>
            <Parameter name="port" value="8080"/>
        </Connector>

        <Connector className="org.apache.tomcat.service.SimpleTcpConnector">
            <Parameter name="handler" value="org.apache.tomcat.service.connector.Ajp12ConnectionHandler"/>
            <Parameter name="port" value="8007"/>
        </Connector>

        <!-- example - how to override AutoSetup actions -->
        <Context path="/examples" docBase="webapps/examples" debug="9" reloadable="true" > 
        </Context>
        <!-- example - how to override AutoSetup actions -->
        <Context path="" docBase="webapps/ROOT" debug="9" reloadable="true" > 
        </Context>

        <Context path="/test" docBase="webapps/test" debug="9" reloadable="true" > 
        </Context>

    </ContextManager>
</Server>
------------------------

http.conf:
------------------------
ServerType standalone
ServerRoot "d:/apache"
PidFile logs/httpd.pid
ScoreBoardFile logs/apache_status
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
MaxRequestsPerChild 0
ThreadsPerChild 50
Port 80
ServerAdmin you@your.address
DocumentRoot "d:/apache/htdocs"
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory "d:/apache/htdocs">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
UserDir "d:/apache/users/"
DirectoryIndex index.html
AccessFileName .htaccess
<Files .htaccess>
    Order allow,deny
    Deny from all
</Files>
UseCanonicalName On
TypesConfig conf/mime.types
DefaultType text/plain
<IfModule mod_mime_magic.c>
    MIMEMagicFile conf/magic
</IfModule>
HostnameLookups Off
ErrorLog logs/error.log
LogLevel debug
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
CustomLog logs/access.log common
ServerSignature On
Alias /icons/ "d:/apache/icons/"
ScriptAlias /cgi-bin/ "d:/apache/cgi-bin/"
<Directory "d:/apache/cgi-bin">
    AllowOverride None
    Options None
</Directory>
IndexOptions FancyIndexing
AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip
AddIconByType (TXT,/icons/text.gif) text/*
AddIconByType (IMG,/icons/image2.gif) image/*
AddIconByType (SND,/icons/sound2.gif) audio/*
AddIconByType (VID,/icons/movie.gif) video/*
AddIcon /icons/binary.gif .bin .exe
AddIcon /icons/binhex.gif .hqx
AddIcon /icons/tar.gif .tar
AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
AddIcon /icons/a.gif .ps .ai .eps
AddIcon /icons/layout.gif .html .shtml .htm .pdf
AddIcon /icons/text.gif .txt
AddIcon /icons/c.gif .c
AddIcon /icons/p.gif .pl .py
AddIcon /icons/f.gif .for
AddIcon /icons/dvi.gif .dvi
AddIcon /icons/uuencoded.gif .uu
AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
AddIcon /icons/tex.gif .tex
AddIcon /icons/bomb.gif core
AddIcon /icons/back.gif ..
AddIcon /icons/hand.right.gif README
AddIcon /icons/folder.gif ^^DIRECTORY^^
AddIcon /icons/blank.gif ^^BLANKICON^^
DefaultIcon /icons/unknown.gif
ReadmeName README
HeaderName HEADER
IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
AddEncoding x-compress Z
AddEncoding x-gzip gz tgz
AddLanguage da .dk
AddLanguage nl .nl
AddLanguage en .en
AddLanguage et .ee
AddLanguage fr .fr
AddLanguage de .de
AddLanguage el .el
AddLanguage it .it
AddLanguage pt .pt
AddLanguage ltz .lu
AddLanguage ca .ca
AddLanguage es .es
AddLanguage sv .se
AddLanguage cz .cz
LanguagePriority en da nl et fr de el it pt ltz ca es sv
AddType application/x-tar .tgz
BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
BrowserMatch "RealPlayer 4\.0" force-response-1.0
BrowserMatch "Java/1\.0" force-response-1.0
BrowserMatch "JDK/1\.0" force-response-1.0
Include d:/jakarta-tomcat/conf/tomcat-apache.conf
------------------------

-- 
===============================================================================
David M. Karr     ; dkarr@tcsi.com  ; w:(425)487-8312 ; TCSI & Best Consulting
Software Engineer ; Unix/Java/C++/X ; BrainBench CJ12P (#12004)


RE: Tomcat: Options for installing HTML "close" to classes?

Posted by "Rob S." <rs...@home.com>.
> Ok, and how exactly do you specify a URL to reference that?  I would
> have guessed "http://localhost/<file>", but that doesn't work.  From
> the logs, it doesn't appear as if Tomcat is even getting the request
> for the file.  It is handled (and failed) solely by Apache.

That all depends on your Apache/Tomcat setup.  Could you paste the pertinent
section(s) of your server.xml and httpd.conf?

How would you like it to be accessed?

- r


Re: Tomcat: Options for installing HTML "close" to classes?

Posted by "David M. Karr" <dk...@tcsi.com>.
>>>>> "Rob" == Rob S <rs...@home.com> writes:
  >> $TOMCAT_HOME/webapps hierarchy so it will work.  Is it
  >> feasible/practical to do this?

  Rob> I believe it should be in "$TOMCAT_HOME/webapps/ROOT/"

  Rob> That's the standard place files for a context go (in your case).

Ok, and how exactly do you specify a URL to reference that?  I would
have guessed "http://localhost/<file>", but that doesn't work.  From
the logs, it doesn't appear as if Tomcat is even getting the request
for the file.  It is handled (and failed) solely by Apache.

-- 
===============================================================================
David M. Karr     ; dkarr@tcsi.com  ; w:(425)487-8312 ; TCSI & Best Consulting
Software Engineer ; Unix/Java/C++/X ; BrainBench CJ12P (#12004)


RE: Tomcat: Options for installing HTML "close" to classes?

Posted by "Rob S." <rs...@home.com>.
> $TOMCAT_HOME/webapps hierarchy so it will work.  Is it
> feasible/practical to do this?

I believe it should be in "$TOMCAT_HOME/webapps/ROOT/"

That's the standard place files for a context go (in your case).

- r