Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tomcat document root

Status
Not open for further replies.

excession

Programmer
Sep 22, 2004
111
GB
I've got:

tomcat 5 (c:\tomcat\Tomcat5)
apache 2 (c:\apache\Apache2)
html docs (c:\public)

I can set acpache to use the c:\public as a document root, but can't seem to get Tomcat to do the same, so in order to get jsp's working they have to be in the tomcat htdocs directory.

How do i configure the apache tomcat setup so that all documents are in c:\public (both static html and jsp)?

 
Configure your webapp context like this :

<Context path="/myWebapp" docbase="C:/public" debug="0" reloadable="true" />

This assumes that you have a dir called C:/public/myWebapp , which if it had an "index.html" file, the URL would be :


--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
this may sound like a daft question, but which file would that line be in? I'm trying to get a simple test jsp to work first before trying to deploy the main web app. It's just the date.jsp example provided with tomcat. I've put it in a folder c:\public\date but the url doesn't work. I either get a tomcat 'not found' or apache serving the request (obviously with no jsp).

When I get the date.jsp working I'll try the full webapp
 
Add it in the <Host> section of server.xml

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
I still can't get this to work....
I've put the line
<Context path="/dates" docbase="C:/public/dates" debug="0" reloadable="true" />
in tomcats server.xml

If I try http:\\localhost\dates apache serves the request without the jsp working
If I try http:\\localhost:8080\dates tomcat returns with a 404-not found error.

If I try the http:\\localhost\jsp-examples then I get the jsp examples served by tomcat fine

Any ideas? If needbe I don't mind posting the conf files if that will help.
 
In my example above, I said the docbase was C:/public - not including the webapp name :

<Context path="/dates" docbase="C:/public" debug="0" reloadable="true" />

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
[blush] oops, sorry.

Even correcting that still has no effect

Somehow I seem to have something fundamentally wrong in the config, I must admit I'm a complete novice as far as apache/tomcat are concerned and I've just been following the howto guides I've found.

I've put an entry in the mod_jk.conf file :
Code:
# Static files 
    Alias /dates "C:/public/dates"

    <Directory "C:/public/dates">
        Options Indexes FollowSymLinks
        DirectoryIndex index.html index.htm index.jsp 
    </Directory>


    # Deny direct access to WEB-INF and META-INF
    #
    <Location "/dates/WEB-INF/*">
        AllowOverride None
        deny from all
    </Location>

    <Location "/dates/META-INF/*">
        AllowOverride None
        deny from all
    </Location>
    #
    # Use Directory too. On Windows, Location doesn't work unless case matches
    #
    <Directory "C:/public/dates/WEB-INF/">
        AllowOverride None
        deny from all
    </Directory>

    <Directory "C:/public/dates/META-INF/">
        AllowOverride None
        deny from all
    </Directory>

    JkMount /dates  ajp13
    JkMount /detes/*.jsp  ajp13

and the line in server.xml now reads:

Code:
<Context path="/dates" docbase="C:/public" debug="0" reloadable="true" />

just after the line
Code:
<Host name="localhost" debug="0" appBase="webapps"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">

Where am I going wrong?



 
Try :
Code:
<Host name="localhost" debug="0" appBase="C:/public"
		unpackWARs="true" autoDeploy="true"
		xmlValidation="false" xmlNamespaceAware="false">

	<Context path="/date" debug="0" reloadable="true" />

</Host>

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Still does not process the jsp pages. If anything things are worse, I now only get apache 404-not found errors and nothing from tomcat even if i specify the 8080 port, and tomcats home page (localhost:8080) is not found either (the service is running.

help!

 
Well tomcat's homepage wouldn't be found because that is in the default ROOT webapp - which I doubt is in C:/public .

I can assure you if C:/public/date is a proper webapp, then :

will work.

But of course nothing else in TOMCAT_HOME/webapps is going to work, because you've just told Tomcat that all of its webapps for "localhost" are to be loaded from C:/public.

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
A host entry normally points to a document folder that has a ROOT folder. This would serve the default context; myhost.com/

In the host entry you can add a context /manager that points to the real (original) location of the webapps of the manager app; tomcat_home/server/webapps/manager. Then you can use the manager from the virtual host as well. (Same theory for /admin...)

Jeb Beasley
\0
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top