File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Running servlet in tomcat

 
ramdas pradeep kumar
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to the Tomcat. I got a servlet project from someone else.
I've deployed the war file in the webapps dir.
It extracted the files and in the web-inf/classes dir and so many sub folders have been created as per the package structure. there is one servlet class in the innermost folder.
how can i call the servlet directly
any properties need to be changed in xml files, etc
 
Malhar Barai
Author
Ranch Hand
Posts: 399
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by ramdas pradeep kumar:
I am new to the Tomcat. I got a servlet project from someone else.
I've deployed the war file in the webapps dir.
It extracted the files and in the web-inf/classes dir and so many sub folders have been created as per the package structure. there is one servlet class in the innermost folder.
how can i call the servlet directly
any properties need to be changed in xml files, etc

Hi Pradeep
Do check the web.xml file, do you find any thing like startup tag, also check for the Servlet Context in server.xml file, you mite need to add a context..
hth
MB
 
Faisal Khan
Ranch Hand
Posts: 285
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe it can be done as following:
http://localhost:8080/myapp/servlet/com.abc.test.hello.MySerlvet
hth
 
ramdas pradeep kumar
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai malhar,
u mean the xml files in the config dir? can you explain me please.
i found the following in server.xml
<Context path="/examples" docBase="examples" debug="0"
reloadable="true" crossContext="true">

a segment from web.xml
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>
org.apache.catalina.servlets.DefaultServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
[ September 19, 2003: Message edited by: ramdas pradeep kumar ]
 
ritchie diputado
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi heres a sample xml configuration for servlet:
<servlet>
<servlet-name>myservlet</servlet-name>
<servlet-class>mypackage.anotherpackage.MyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>myservlet</servlet-name>
<url-pattern>/myservlet</url-pattern>
</servlet-mapping>

Now you can call this serverlet by:
http://localhost:8080/mycontext/myservlet
Hope it helps
Ritchie Diputado
 
Malhar Barai
Author
Ranch Hand
Posts: 399
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by ramdas pradeep kumar:
hai malhar,
u mean the xml files in the config dir? can you explain me please.
i found the following in server.xml
<Context path="/examples" docBase="examples" debug="0"
reloadable="true" crossContext="true">


The context is in server.xml indeed in the "conf" directory...


a segment from web.xml
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>
org.apache.catalina.servlets.DefaultServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

The web.xml in the WEB-INF directory...
The following should be your directory structure
-bin
-conf
|- server.xml
|- tomcat-users.xml
|- web.xml(x - This is on the web.xml, we hv to use...)
-...
-webapps
|- examples(Contains examples)
|- <context you define>
|- WEB-INF(inside your context)
|- web.xml(inside WEB-INF)
-...
hth
MB
[ September 19, 2003: Message edited by: Malhar Barai ]
[ September 19, 2003: Message edited by: Malhar Barai ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic