File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes TOMCAT Configuration Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "TOMCAT Configuration Question" Watch "TOMCAT Configuration Question" New topic
Author

TOMCAT Configuration Question

zheng yu
Greenhorn

Joined: Apr 25, 2001
Posts: 28
I have installed TOMCAT on a linux server successfully , that means i can see the things under examples directory .
( All the jsp/servlet samples under example directory is OK )
But when i make a new directory named myproj under webapp/ directory and copy some servlet samples to myproj .server always tell me that "the servlet was not found ", when i change the servlet to jsp , it works properly .( i think this means myproj context has been recognized by TOMCAT )
I am really puzzled . can someone tell me how to solve this problem ?
(when i copy these sample servlets to TOM_CAT_HOME/webapp/examples directory , it works perfectly )
Environ :
Turbolinux / Oracle8i /Tomcat3.2.1/JDK1.2.2
folder tree is show as follow :
TOMCAT_HOME
webapp
examples
META-INF
WEB-INF
JSP
servlets
images
samples
META-INF
WEB-INF
jservlets-examples
images
...
Does someone has created your own app directory under TOMCAT_HOME/webapp directory( like TOMCAT_HOME/webapp/examples) , that can handle jsp/jservlet requests properly , and can show the directory structure in browser( If u input the web address like http://mysite/examples ) ? if u did it , please tell me step by step . i am not as clever as u
ZY



Phil Hanna
Ranch Hand

Joined: Apr 05, 2001
Posts: 118
If you have /webapps/myproj, you need a WEB-INF directory under that with the following:
webapps/myproj/WEB-INF/web.xml
webapps/myproj/WEB-INF/classes/MyServlet.class
and in web.xml you should define your servlet:
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>MyServlet</servlet-class>
</servlet>
then restart Tomcat and try http://localhost:8080/myproj/MyServlet.
Look at the WEB-INF directory in the example webapp and use that as a model. It has a complete web.xml that you can adapt.
------------------
Phil Hanna
Sun Certified Programmer for the Java 2 Platform
Author of :
JSP: The Complete Reference
Instant Java Servlets


Phil Hanna<BR>Sun Certified Programmer for the Java 2 Platform<BR>Author of :<BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/0072127686/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">JSP: The Complete Reference</A><BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/0072124253/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">Instant Java Servlets</A>
zheng yu
Greenhorn

Joined: Apr 25, 2001
Posts: 28
Thanx for your reply
But before i posted this question , i had checked it .
(i have read TOMCAT's online document serveral times )
first , i declare i have the same directory srtucture
like examples , and i do place my servlet class under
TOMCAT_HOME/webapp/myproj/WEB-INF/ .
next i copyed the Web.xml file from examples directory,
and just appended one servlet tag ( <servlet> </servlet> pair)
what i dont know is the contents of web.xml and how to write it
from scratch even after i have read sun's servlet specification
but anyway i will check it again

Need your help
ZY
zheng yu
Greenhorn

Joined: Apr 25, 2001
Posts: 28
Let me describe my situation
First , Some one setup an apache server , and set its port to 8080
then I installed TOMCAT . and some one comment the following Element :
<!--
< Connector className="org.apache.tomcat.service.PoolTcpConnector">
< Parameter Name="handler"
value="org.apache.tomcat.service.http.HeepConnectionHandler"/>
<Parameter name="port" value="8080"/>
</Connector>
-->
if i uncomment this <Connector> </Connector> pair , TOMCAT's Startup failed because of BindException , so i think that must be a port confliction . after i changed the port to 8011 , and input some url
in my browser like : http://site address:8011/myproj/servlet/CurrentTime, it works( myproj is my application , and CurrentTime is a simple servlet sample class )
so i think what u all tell me is all right . The reason is my environment , port confliction to be exactly . What's your explanation ?
can't apache and Tomcat share the same port ?

Thanx again
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: TOMCAT Configuration Question