• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Running servlet in tomcat

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
There's a city wid manhunt for this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic