• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Path to servlet

 
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Andrew Parker
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic