NEED HELP SETTING UP TOMCAT 4.1.29

M

Marc

Hi,

I've got a test prep book and I'm trying to prepare for the Sun
Certified Web Component Developer exam. Unfortunately, I've run into
a problem with Tomcat.

The problem that I've run into is that I can't get a simple HelloWorld
servlet to work (Yes, I know. It's pretty embarrassing). The problem
is that Tomcat tells me "404 resource not available" whenever I try to
access the servlet:

http://localhost:8080/chapter01/servlet/HelloWorldServlet

I've placed the servlet class file (Copied it straight off the CD that
came with the book) in my
D:\jakarta-tomcat-4.1.29\webapps\chapter01\WEB-INF\classes directory
and I've placed the web.xml file in my
D:\jakarta-tomcat-4.1.29\webapps\chapter01\WEB-INF directory.

The web.xml file reads:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!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>

<display-name>chapter01</display-name>
<description>
Chapter 01 Example Servlet.
</description>

<servlet>
<servlet-name>HelloWorldServlet</servlet-name>
<servlet-class>HelloWorldServlet</servlet-class>
</servlet>

</web-app>

I'm pretty sure I've set up Tomcat correctly because I can get to the
simple JSP page located at http://localhost:8080/index.jsp and I can
log in and play around with the Tomcat Web Application Manager. I've
used the Web Application Manager to stop and start and reload the
chapter01 application I don't know how many times.

Any help that anyone can provide will be greatly appreciated.

Thanks,
Marc
 
G

Guest

You might miss servlet mapping:

<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/servlet/HelloWorld</url-pattern>
</servlet-mapping>
<servlet>
 
M

Markku Salminen

is that Tomcat tells me "404 resource not available" whenever I try to
access the servlet:

http://localhost:8080/chapter01/servlet/HelloWorldServlet

I've placed the servlet class file (Copied it straight off the CD that
came with the book) in my
The web.xml file reads:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!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>

<display-name>chapter01</display-name>
<description>
Chapter 01 Example Servlet.
</description>

<servlet>
<servlet-name>HelloWorldServlet</servlet-name>
<servlet-class>HelloWorldServlet</servlet-class>
</servlet>

You also need servlet mapping:

<servlet-mapping>
<servlet-name>HelloWorldServlet</servlet-name>
<url-pattern>/HelloWorld</url-pattern>
</servlet-mapping>


Then deploy your app again and try:
http://localhost:8080/chapter01/servlet/HelloWorld

If it still not working then check your context root.
 
H

hiwa

Hi,

I've got a test prep book and I'm trying to prepare for the Sun
Certified Web Component Developer exam. Unfortunately, I've run into
a problem with Tomcat.

The problem that I've run into is that I can't get a simple HelloWorld
servlet to work (Yes, I know. It's pretty embarrassing). The problem
is that Tomcat tells me "404 resource not available" whenever I try to
access the servlet:

http://localhost:8080/chapter01/servlet/HelloWorldServlet

I've placed the servlet class file (Copied it straight off the CD that
came with the book) in my
D:\jakarta-tomcat-4.1.29\webapps\chapter01\WEB-INF\classes directory
and I've placed the web.xml file in my
D:\jakarta-tomcat-4.1.29\webapps\chapter01\WEB-INF directory.

The web.xml file reads:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!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>

<display-name>chapter01</display-name>
<description>
Chapter 01 Example Servlet.
</description>

<servlet>
<servlet-name>HelloWorldServlet</servlet-name>
<servlet-class>HelloWorldServlet</servlet-class>
</servlet>

</web-app>

I'm pretty sure I've set up Tomcat correctly because I can get to the
simple JSP page located at http://localhost:8080/index.jsp and I can
log in and play around with the Tomcat Web Application Manager. I've
used the Web Application Manager to stop and start and reload the
chapter01 application I don't know how many times.

Any help that anyone can provide will be greatly appreciated.

Thanks,
Marc

You are using invoker servlet. Isn't it disabled in Tomcat config?
Also, you may need servlet-mapping entry in the web.xml file.
 
M

Marc

Thank you very much Markku!

I made the change you suggested below. I am able to get my Hello
World page by pointing my browser to this address:

http://localhost:8080/chapter01/HelloWorld

The book I am using to study for the exam did not mention that I
needed <servlet-mapping> in my web.xml file (The book does not even
mention servlet-mapping until chapter 5).

Thanks again,
Marc
 
M

Marc

Thank you very much Jan!

I also made the change you suggested below. I am able to get my Hello
World page by pointing my browser to this address:

http://localhost:8080/chapter01/servlet/HelloWorld

The book I am using to study for the exam did not mention that I
needed <servlet-mapping> in my web.xml file (The book does not even
mention servlet-mapping until chapter 5).

Thanks again,
Marc
 
M

Marc

Thank you for your help Hiwa. As it turns out, servlet mapping was
needed in the web.xml file.

The book I am using to study for the exam did not mention that I
needed <servlet-mapping> in my web.xml file (The book does not even
mention servlet-mapping until chapter 5).

I might try playing around with Tomcat's config file a little later
when I've got some more confidence. For now I'm just happy it works.

Thanks again,
Marc
 

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

Forum statistics

Threads
474,001
Messages
2,570,254
Members
46,849
Latest member
Fira

Latest Threads

Top