• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

cannot invoke servlet in Tomcat

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I have created one servlet MyServlet under webapps/myApp/WEB-INF/classes/com/myappln/MyServlet.java in Tomcat.

For invoking the servlet i give: http://localhost:8080/myApp/servlet/com.myappln.MyServlet

The web.xml is:
<web-app>
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>com.myappln.MyServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/servlet/MyServlet</url-pattern>
</servlet-mapping>
</web-app>

So with this config, i am unable to invoke my servlet and it gives a 404.

Have i missed out something, please do help.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It should work with something like the following. Two hints: avoid "/servlet/" in URLS (read here why), and you use the url-pattern in the URL, not the servlet-class.

The URL is http://localhost:8080/myApp/MyServlet


<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>com.myappln.MyServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/MyServlet</url-pattern>
</servlet-mapping>


[ July 11, 2006: Message edited by: Ulf Dittmer ]
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try that
http://localhost:8080/myApp/servlet/MyServlet



that where you define the url to trigger your servlet
ps i'm not sure about the first /
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic