wood burning stoves 2.0*
The moose likes Tomcat and the fly likes tomcat doesn't see my servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "tomcat doesn Watch "tomcat doesn New topic
Author

tomcat doesn't see my servlet

Peter Bergoff
Ranch Hand

Joined: Apr 07, 2004
Posts: 103
Hi everyone,

I'm sure this is an easy one but can't figure it out . . .

I have a servlet which can't be found by tomcat. Following is my setup:

servlet class is in WEB-INF/classes/mlo

I am attempting to request as follows:
http://www.xxxx.com/mlo/servlet/mlo.UserSignIn

I have the follwoing in my web.xml:
<servlet>
<servlet-name>mlo.UserSignIn</servlet-name>
<servlet-class>mlo.UserSignIn</servlet-class>
</servlet>

Anything look funny?

Thanks,

Peter
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You don't have a servlet mapping.

In older versions of Tomcat, there was a mechanism called the InvokerServlet that would allow you to call servlets by package & classname from your URL.
This feature has been disabled in recent versions.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Peter Bergoff
Ranch Hand

Joined: Apr 07, 2004
Posts: 103
Ah, so from some quick reading on this topic I would guess I need to add the following to my web.xml to get the servlet to work:

<servlet-mapping>
<servlet-name>mlo.UserSignIn</servlet-name>
<url-pattern>mlo.UserSignIn</url-pattern>
</servlet-mapping>

I'm sure this is defeating the security reasons it should be used but just trying to get a basic idea of what's going on. Does that look right?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Peter Bergoff:
Does that look right?


Almost.
You've got "/servlet" in your URL.
You can either remove that from the URL or add it to your mapping.
If you want to get a quick "Hello, World" servlet up and running in about 15 seconds download SimpleServlet.war from our CodeBarn to your tomcat/webapps directory.

http://faq.javaranch.com/java/CodeBarnSimpleServlet
Peter Bergoff
Ranch Hand

Joined: Apr 07, 2004
Posts: 103
Okay, so here's what I understand:

To run this servlet:

http://www.xxxx.com/mlo/servlet/mlo.UserSignIn

I need this mapping in my web.xml:

<servlet>
<servlet-name>mlo.UserSignIn</servlet-name>
<servlet-class>mlo.UserSignIn</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>mlo.UserSignIn</servlet-name>
<url-pattern>/servlet/mlo.UserSignIn</url-pattern>
</servlet-mapping>
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Is it working for you?
Peter Bergoff
Ranch Hand

Joined: Apr 07, 2004
Posts: 103
No, it didn't work.

I was trying a lot of different things and tried this:

<servlet>
<servlet-name>mlo.UserSignIn</servlet-name>
<servlet-class>mlo.UserSignIn</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>mlo.UserSignIn</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>

It mapped everything to the UserSignIn servlet.

I don't get it. Can anyone show me how this should work?
[ May 30, 2008: Message edited by: Peter Bergoff ]
Peter Bergoff
Ranch Hand

Joined: Apr 07, 2004
Posts: 103
Got it!

<servlet>
<servlet-name>UserSignIn</servlet-name>
<servlet-class>mlo.UserSignIn</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>UserSignIn</servlet-name>
<url-pattern>/servlet/mlo.UserSignIn</url-pattern>
</servlet-mapping>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: tomcat doesn't see my servlet
 
Similar Threads
Tomcat not seeing servlet
jstl problem in Spring MVC
servlet-mapping doesn't do its job?
Security Problem
Deploying the application