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

tomcat doesn't see my servlet

 
Peter Bergoff
Ranch Hand
Posts: 103
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Peter Bergoff
Ranch Hand
Posts: 103
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 103
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
 
Peter Bergoff
Ranch Hand
Posts: 103
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 103
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic