It's not a secret anymore!
The moose likes Servlets and the fly likes Path to servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Path to servlet" Watch "Path to servlet" New topic

Path to servlet

Andrew Parker
Ranch Hand

Joined: Nov 12, 2001
Posts: 178
I created a servlet which included in a package and the class is CheckinServlet.
I created a dir "abc" under /var/tomcat4/webapps/. So, /var/tomcat4/webapps/abc/index.jsp will be shown when I browsed it at http://localhost:8080/abc/index.jsp.
In the index.jsp, I have a form action=/abc/servlet/
And the CheckinServlet.class was placed in /var/tomcat4/webapps/abc/WEB-INF/classes/com/abc/web/Checkin/CheckinServlet.class.
However, the browser returns that there is no such page: http://localhost:8080/abc/servlet/
Why and how can I fix this problem? Where should I place the servlet and be defined in form action?
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
You would be better off creating an entry for the servlet in the web.xml for your "abc" web application. That way you could address it with a short URL. See the Tomcat examples/WEB-INF/web.xml for examples with explanation.
Download the servlet API from for the full details on what goes in a web.xml.
Andrew Parker
Ranch Hand

Joined: Nov 12, 2001
Posts: 178
Dear Sir,
In fact, I have a web.xml file which located at /webapps/abc/WEB-INF/web.xml.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "">
But, it still did not work. Any idea?
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

In web.xml, the <servlet> element should be thought of as "back-end" and hidden.

The <servlet-mapping> on the other hand, is the opposite. It is the front-side and 'public' interface to your application classes.

So in this case, your form action tag should be submitting to "/CheckinServlet", not the fully qualified class name of what should be a private class.
I agree. Here's the link:
subject: Path to servlet
It's not a secret anymore!