Servlet not running in ant built tomcat application

N

Nara Bala

I am doing my first servlet based web application. That accepts a name
and email and upon clicking the submit button, invokes a servlet to
print a welcome message. The code was taken from a book - professional
JSP.
I created this application from my own directory space. I created the
required directory structure and created the build directory with
ant. I then installed the application in tomcat using ant again. Now
the index.html page is shown in the web browser. However upon clicking
the submit button, the page displays 404 error for the servlet. I have
played around with the web.xml a lot...

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<!-- Servlet alias -->
<servlet-name>Registration</servlet-name>
<!-- Fully qualified Servlet class -->
<servlet-class>GreetingServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Registration</servlet-name>
<url-pattern>/Registration</url-pattern>
</servlet-mapping>

</web-app>

Kindly tell me what i am missing........

thanks
Nara
 
M

Marko Lahma

Be sure that you class file resides in directory
<web-app-root>/WEB-INF/classes , then make sure that your servlet hasn't
any package specified, this would be included in the <servlet-name> tag,
like com.test.servlet.GreetingServlet

If you see the index page the app should be correclty located under
Tomcat. But to be sure maybe you should go through Tomcat web-app setup
tutorial too.

-Marko
 
J

John C. Bollinger

Marko said:
Be sure that you class file resides in directory
<web-app-root>/WEB-INF/classes , then make sure that your servlet hasn't
any package specified, this would be included in the <servlet-name> tag,
like com.test.servlet.GreetingServlet

On the contrary, make sure the servlet class _does_ have a package, and
then specifiy that package in your web.xml (otherwise the class name is
not fully qualified). You are highly likely to run into problems if you
try to use classes from the default package in this kind of environment.


John Bollinger
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top