aspose file tools*
The moose likes Tomcat and the fly likes cannot invoke servlet in Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "cannot invoke servlet in Tomcat" Watch "cannot invoke servlet in Tomcat" New topic
Author

cannot invoke servlet in Tomcat

Mickey Smith
Ranch Hand

Joined: Jun 26, 2006
Posts: 30
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.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39541
    
  27
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 ]

Ping & DNS - updated with new look and Ping home screen widget
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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 /
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: cannot invoke servlet in Tomcat
 
Similar Threads
trouble loading servlet class on Tomcat4.1.24
web.xml within tomcat
How to run servlet on Tomcat
Difficulties with setting up Apache tomcat: 'Need a little help.
Cannot Compile Servlet with Tomcat