This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Need someone to verify syntax in Tomcat servlet.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Need someone to verify syntax in Tomcat servlet.xml" Watch "Need someone to verify syntax in Tomcat servlet.xml" New topic

Need someone to verify syntax in Tomcat servlet.xml

Jaime Lannister

Joined: Mar 30, 2005
Posts: 18
Well, I think I have either the right syntax or very close to the right syntax in my Tomcat Server.xml host section. Based on what the Catalina.out file is saying, Tomcat seems to be recognizing where the webapp that contains my Java servlets is located. It says it is "deploying" all of the .jar files in its own default directory library to the WEB-INF/lib directory in my site directory. However, things still aren't working (Apache doesn't seem to recognize that "/servlet/" means "send this request over to Tomcat!" instead of a directory named "/servlet" and is not calling on Tomcat.) I am hoping that someone can verify that I have everything right in the <host> section of servlet.xml before I go look at Apache's files:

The relevant information for my server and the test site I am running on it is:
I am using a dedicated server set up by my web host (which doesn't provide tech support related to Tomcat or Apache).
I am running Tomcat 4.06 with Apache 2.0.(X) under Linux.
I am trying to get Tomcat to handle servlets.
My domain name is registered, but not yet assigned to the URL number of the server, so I have to type in http://myURLnumber/ to access the site. I apparently have to use the same within the server.xml file, at least, it seems to work.
The complete pathname to my site, which is a name based virtual site, is /home/virtual/site1/fst/var/www/html
Within that directory are all the elements that are considered a "web application" including all my html files, a web.xml file, and a WEB-INF folder which contains lib, jsp,and classes folders (the servlet class fiels are in the latter).

This is what I currently have in this <host> section of the server.xml NOTE: If there are any "<" and ">" tags missing it's because I had to take them out - this bulletin board rejects messages with certain html or javascript in it.

<Host name="myURLnumber/mydomainname" appbase="/home/virtual/site1/fst/">
<Context path="myURLnumber/mydomainname" docBase="/home/virtual/site1/fst/var/www/html" />

Is this right? If not, can someone please fill in the blanks, given the path to the webapp given above?

name = "______________"
Context path="_______________"

I've read the Tocmat documentation and several other explanations of this and I'm still not absolutely certain what is supposed to go in each part.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
This method of creating a URL baffles me:

What is supposed to detect the fact that "mydomainname" is supposed to be interpreted as if it was the actual URL host?
Assuming that Apache detects this, does it re-write the request or what?
[ August 07, 2005: Message edited by: William Brogden ]
Jaime Lannister

Joined: Mar 30, 2005
Posts: 18
See my response to your similar question in my last post.

"mydomainame" currently is registered to (or whatever you call it) another server with another numerical (XX.X.XXX.XXX) address at the same web host. When you type in http://mydomainame/, you get the first page of my website, which is currently sitting on that other server. The other server is a shared server that, among other things, does not support Tomcat or Java servlets.

Thus I have rented a new dedicated server, but do not want to transfer the website over to it until I get certain things working properly on it. This new server has a different address (YY.Y.YYY.YYY), and a test version of the website exists as a virtual site on it. If you type in http://YY.Y.YYY.YYY/mydomainame, you get sent down to the test copy of the first web page.

A program called "Ensim" takes care of setting this up. Ensim is a site admin program with a GUI interface that lets you do things like set up new sites, start and stop Apache and other programs, etc. You create a site by
typing info into fields and it automcatically sets up the right directory structure in the right place, and directs things to it. I believe that this
all done by automatically adding info to files that are appended (via include statements?) to Apache's configuration files, but I don't know the ins and outs of it yet.

My question still is, ASSUMING for now that /myURLnumber/mydomainame is the correct syntax to use, what goes in the other parts of the <host> statement -

name = "______________"
Context path="_______________"

I agree. Here's the link:
subject: Need someone to verify syntax in Tomcat servlet.xml
It's not a secret anymore!