| Author |
Path to servlet
|
Andrew Parker
Ranch Hand
Joined: Nov 12, 2001
Posts: 178
|
|
Hi, I created a servlet which included in a package com.abc.web.Checkin 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/com.abc.web.Checkin.CheckinServlet 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/com.abc.web.Checkin.CheckinServlet Why and how can I fix this problem? Where should I place the servlet and be defined in form action? Thanks Andrew
|
 |
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12266
|
|
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 java.sun.com for the full details on what goes in a web.xml. Bill
|
Java Resources at www.wbrogden.com
|
 |
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" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <servlet> <servlet-name>CheckinServlet</servlet-name> <servlet-class>com.abc.web.Checkin.CheckinServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>CheckinServlet</servlet-name> <url-pattern>/CheckinServlet</url-pattern> </servlet-mapping> </web-app> But, it still did not work. Any idea? Regards Andrew
|
 |
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.
|
 |
 |
|
|
subject: Path to servlet
|
|
|