You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Tent Pig <te...@yahoo.com> on 2007/06/22 15:54:15 UTC

Configuring TOMCAT to use different ROOT context

Hi everyone.

I'm sorry if this seems like a newbie question,
unfortunately I'm a complete neophyte when it comes to
tomcat setup and configuration.

I have a user who manages website content, setup and
administration of the linux server falls upon me. On
this web server my user has several websites hosted
via apache virtual hosts. She would like to start
incorporating JSP pages into her sites.

I installed an configured the mod_jk.so module on
apache -- works great. I created a few 'test.jsp'
pages and put them in $TOMCAT_HOME/webapps/ROOT and
was able to access them by going to
http://mysite/test.jsp. Thus, Tomcat seems to be
working file, and apache is correctly handing off the
requests to tomcat which is responding correctly.


Although my user would like to integrate JSP pages
into her websites, she wants to be able to maintain
all her files within the DocumentRoot folders of her
virtual hosts -- she doesn't want to have to update
both the DocumentRoot folder of the apache virtual
hosts and the "webapps" directory structure of Tomcat
with her JSP pages.

Plus, she has different JSP pages for each virtual
host and doesn't want to 'mix and match' them. In
other words, if 'myfile.jsp' is only available on
virtualhost1, she doesn't want someone to be able to
go to http://virtualhost2/myfile.jsp, as she has me
restrict access to various virtual hosts by IP subnet.


So, to start off I attempted to update Tomcat's
'server.xml' to change the default context to point to
the same DocumentRoot folder, but this apparently
doesn't work (or, more appropriately, I'm not doing it
correctly).

I had googled various phrases on how to do this, and I
found a lot of useless information, or references to
files/clauses in various config files that no longer
exist. The information I found, when I attempted to
use it, didn't work.

For what its worth, I currently have CentOS 5 running,
which has apache 2.2.3 and tomcat 5.5.23.

I reviewed the Tomcat help pages, which provide nice
syntaxical information, but seem to fall short in
providing me lots of useful examples on how to
accomplish what I'm trying to do.

So...

Can someone provide me with a brief example of how I
configure Tomcat to look for JSP pages within each
virtual hosts's DocumentRoot directory structure, and
how to keep each virtual hosts's applications
segregated?

Thanks,

Vin


       
____________________________________________________________________________________
Building a website is a piece of cake. Yahoo! Small Business gives you all the tools to get online.
http://smallbusiness.yahoo.com/webhosting 

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Configuring TOMCAT to use different ROOT context

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Tent Pig [mailto:tentpig@yahoo.com] 
> Subject: RE: Configuring TOMCAT to use different ROOT context
> 
> The problem I'm encountering is a request to:
> http://path/to/sectionx/test.jsp
> will yield an error 400, bad request.

Are you sure it's even getting to Tomcat?  What happens if you try going
directly to Tomcat's HTTP port?

> I placed a:
> <Valve
> className="org.apache.catalina.valves.RequestDumperValve"
> />
> 
> in my server.xml, but it seems to have no impact on
> the output contained in my log file.

Where in server.xml did you put it?  Inside <Engine> might be best for
this purpose.

You could also try the AccessLogValve which is already there, just
commented out.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Configuring TOMCAT to use different ROOT context

Posted by Tent Pig <te...@yahoo.com>.
--- "Caldarale, Charles R"
<Ch...@unisys.com> wrote:

> I hope you're more careful with proper casing than
> the above would lead us to believe. If the above is 
> really what you put in, it would have no
> effect, since both the element and attributes are
> incorrect.

My casing is AFAIK correct in server.xml, I'm typing
this freehand so I'm more 'lax', rather than cutting
and pasting.


> Does sectionx correspond to a virtual host or an
> application?  

No, I'm only working on the first virtual host at the
moment, I have to get it working on that one first :)

She wants to have her apps for each virtualhost in
respective subdirectories (she has an existing
directory structure she's working with and doesn't
want to change).

The problem I'm encountering is a request to:

http://path/to/sectionx/test.jsp

will yield an error 400, bad request.


> If application, then the URI received by Tomcat
> doesn't match; enable the RequestDumperValve to see
> what's really coming in.

I placed a:

<Valve
className="org.apache.catalina.valves.RequestDumperValve"
/>

in my server.xml, but it seems to have no impact on
the output contained in my log file.



Thanks,
Vinny


      ____________________________________________________________________________________
Luggage? GPS? Comic books? 
Check out fitting gifts for grads at Yahoo! Search
http://search.yahoo.com/search?fr=oni_on_mail&p=graduation+gifts&cs=bz

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Configuring TOMCAT to use different ROOT context

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Tent Pig [mailto:tentpig@yahoo.com] 
> Subject: RE: Configuring TOMCAT to use different ROOT context
> 
> I put in tomcat's server.xml:
> 
> <host name="localhost" appbase="/path/to/documentroot"
> />

I hope you're more careful with proper casing than the above would lead
us to believe.  If the above is really what you put in, it would have no
effect, since both the element and attributes are incorrect.

> This sort of "works", in the sense that now tomcat
> looks in
> 
> /path/to/documentroot/ROOT/
> 
> for JSP files

Tomcat will only look in ROOT if the request URI doesn't map to any
deployed applications.

> of course, for my user, this is 'unacceptable', since
> she has
> 
> /path/to/documentroot/section1/
> /path/to/documentroot/section2/
> /path/to/documentroot/section3/

Does sectionx correspond to a virtual host or an application?  If
virtual host, then you need to create multiple <Host> elements in
server.xml, one for each section, with the appBase pointing to the
section.  The name attribute of each <Host> must correspond to the
virtual host specified on the request URI.

If application, then the URI received by Tomcat doesn't match; enable
the RequestDumperValve to see what's really coming in.
 
> (Again, I'm completely clueless here) when I googled
> information online, several references were made to
> adding a <context> tag within the <host>
> declaration...

You seem to have encountered badly outdated and erroneous information.
Do not put <Context> elements in server.xml; read the Tomcat doc first:
http://tomcat.apache.org/tomcat-5.5-doc/config/host.html
http://tomcat.apache.org/tomcat-5.5-doc/config/context.html

Then Google, making sure to ignore information that conflicts with the
real doc.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Configuring TOMCAT to use different ROOT context

Posted by Tent Pig <te...@yahoo.com>.
--- "Caldarale, Charles R"
<Ch...@unisys.com> wrote:

> Can you use Tomcat's multiple <Host> capability to
> accomplish this segregation?  Each <Host> element 
> has its own appBase, which could point to the
> appropriate DocumentRoot directory for the
> corresponding httpd virtual host.

Well, I tried this.

I put in tomcat's server.xml:

<host name="localhost" appbase="/path/to/documentroot"
/>


This sort of "works", in the sense that now tomcat
looks in

/path/to/documentroot/ROOT/

for JSP files

of course, for my user, this is 'unacceptable', since
she has

/path/to/documentroot/section1/
/path/to/documentroot/section2/
/path/to/documentroot/section3/

and wants to be able to put applicable JSP pages in
each subdirectory, rather than placing them under
/ROOT

(Again, I'm completely clueless here) when I googled
information online, several references were made to
adding a <context> tag within the <host>
declaration... but if I try this, it seems to have no
effect.

Thanks,

Vin



      ____________________________________________________________________________________
Luggage? GPS? Comic books? 
Check out fitting gifts for grads at Yahoo! Search
http://search.yahoo.com/search?fr=oni_on_mail&p=graduation+gifts&cs=bz

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Configuring TOMCAT to use different ROOT context

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Tent Pig [mailto:tentpig@yahoo.com] 
> Subject: Configuring TOMCAT to use different ROOT context
> 
> Plus, she has different JSP pages for each virtual
> host and doesn't want to 'mix and match' them. In
> other words, if 'myfile.jsp' is only available on
> virtualhost1, she doesn't want someone to be able to
> go to http://virtualhost2/myfile.jsp, as she has me
> restrict access to various virtual hosts by IP subnet.

Can you use Tomcat's multiple <Host> capability to accomplish this
segregation?  Each <Host> element has its own appBase, which could point
to the appropriate DocumentRoot directory for the corresponding httpd
virtual host.  (I've not done this in conjunction with httpd, so I could
easily be missing something.)

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org