File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Still confused - Tomcat Servlet.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Still confused - Tomcat Servlet.xml" Watch "Still confused - Tomcat Servlet.xml" New topic
Author

Still confused - Tomcat Servlet.xml

Jaime Lannister
Greenhorn

Joined: Mar 30, 2005
Posts: 18
After reading more explanations and documentation about what to put in the server.xml file, and the answer to my last post below (see "Confused on a higher plane - Tomcat"), I STILL can't seem to make head nor tail of specifically what goes where in the <host> section of the server.xml file.

The relevant facts about my site are:
I am running on 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/mydomainname/ to access the site (don't know if this effects anyting in server.xml or not).
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, as a far as I know, 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).

Based on my uncertain understanding of various documentation and tutorials, this is what I put in the <host> sections of the server.xml file. NOTE: I took the tag "<" and ">" marks out so that this bb doesn't reject my post for fear of accepting evil html and javascript stuff.


Host name="defaultHost" appbase="/var/www/html"
Context path="" docBase="" /
/Host

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

The first host - /host section was there already, it was my understanding that this had to stay there to define a default host for Tomcat to try in the absence of anything else (there is another webapp directory structure there in /var/www/html with a default placemarker html page in it, put there by the web host).

The second host - /host section is my attempt to tell Tomcat where I want it
to go to get the servlets. I also tried Context path="/mydomainname" (left off the URL number) and a few other minor variations with no luck. I am trying to get a helloworld servlet by typing in http://myURLnumber/mydomainname/servlet/helloworld

The web.xml file seems to be set up OK, the helloworld servlet is listed in there and I am using the correct name for it.

All I get are error messages in the browser that say:
The requested URL /~admin1/servlet/HelloWorldExample was not found on this server.

The Apache logs read "File does not exist: /home/virtual/site1/fst/var/www/html/servlet

What am I getting wrong?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42935
    
  68
Apache apparently does not forward the request to Tomcat, which I am guessing it should do for all requests to your namespace. Given that, the server.xml file probably has nothing to do with the problem, because Tomcat never sees the request. I haven't set up an Apache/Tomcat combo in a long time, so I can't speculate what might be wrong with that.

BTW, I would advise not to use the implicit servlet declaration using "servlet/classname", but to properly register and map your servlet in your web.xml file.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
so I have to type in http://myURLnumber/mydomainname/ to access the site (don't know if this effects anyting in server.xml or not).

As far as I can tell, the name in the Host element must match exactly the way your site is addressed so if you use a numeric address, thats what has to appear in Host name
I have Tomcat serving hosts directly so I don't know what complexities Apache introduces.
Bill
Jaime Lannister
Greenhorn

Joined: Mar 30, 2005
Posts: 18
Re: The Host name - in the first line of the host element,

Host name="_________" appbase="__________"

(Again, I've taken out the "<" ">" symbols because the software running this bulletin board likes to reject things with html tags).

Is the name supposed to be "/myURLnumber/mydomainame"?
If so, what is the Context path=______ supposed to be on the next line?

Re: Apache not calling Tomcat - That may be the case, and I'm trying to find out why. Tomcat's error logs in Catalina.out don't report on anything other than the fact that I turned Tomcat off and on again. I noticed that and the statements in Apache error logs before, and thought maybe the fact that the Tomcat server.xml and web.xml files weren't set up to do anyting with my webbb app were causing it to ignore Apche's requests or something. Anyone have any ideas?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
Is the name supposed to be "/myURLnumber/mydomainame"?

I admit to being totally mystified by that usage. The way I am supporting multiple hosts uses the host domain - like this:

The WROX publication _Professional Apache Tomcat 5_ has a section on configuring Apache to work with virtual hosts on Tomcat in chapt 16.
Bill
Jaime Lannister
Greenhorn

Joined: Mar 30, 2005
Posts: 18
"/myURLnumber/mydomainame" is what I have to type in the browser to get to my dedicated server. The reason for that is that "mydomainame" is not yet registered with that server. "Mydomainame" is currently registered with a different, shared server (which doesn't support Tomcat, Java, etc.), which is where my active site currently resides. I don't want to change the registration until I have everything working properly on, and everything transferred to, the new serever.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Still confused - Tomcat Servlet.xml