Forums Register Login

servlet deployment

+Pie Number of slices to send: Send
hi i am new to servlet. i am learning myself using headfirst jsp and servet. i have read the first chapter in that book. and i tried the example given in that first chapter. i followed the steps like in that book . while running the servlet i am getting error like
HTTP Status 404 - /Ch1/Serv1
type Status report
message /Ch1/Serv1

description The requested resource (/Ch1/Serv1) is not available.

1. i have created directory structure Project1 which has src,classes,etc as sub directory.
2. src has source file
3.etc has web.xml
4.i have build another directory structure under tomcat
tomcat->webapps->Ch1->WEB-INF->classes
5.web-inf has a web.xml and the folder classes, which has class file of the source
6.i started the web server
while running its showing error


can you please any one do the needful. and tell me if any alternative method is there
+Pie Number of slices to send: Send
"newbei.in newbie.in",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff
+Pie Number of slices to send: Send
Could you show the web.xml page
+Pie Number of slices to send: Send
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee

http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
<servlet>
<servlet-name>Chapter1 Servlet</servlet-name>
<servlet-class>Ch1Servlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Chapter1 Servlet</servlet-name>
<url-pattern>Ch1/Serv1</url-pattern>
</servlet-mapping>
</web-app>

this is my web.xml page
+Pie Number of slices to send: Send
"_lakshmi",

You have changed your display name from one that is invalid to one that is even less valid. Please read the following paragraph very carefully:

Your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.


Valid display names are mandatory for participation on the Ranch. Please change your display name as instructed prior to your next post.

Be aware that accounts with invalid display names are disabled.

bear
JavaRanch Sheriff
[ April 24, 2007: Message edited by: Bear Bibeault ]
+Pie Number of slices to send: Send
<servlet>
<servlet-name>Chapter1 Servlet</servlet-name>
<servlet-class>Ch1Servlet</servlet-class>
</servlet>

----------------------------------------------------
please ensure that <servlet-class> tag contains a valid relative path of the actual servlet class you are requesting for.

Putting it simple:

Ch1>
WEB-INF>web.xml
classes>serv1.class
then
<servlet>
<servlet-name>Chapter1Servlet</servlet-name>
<servlet-class>Ch1/Serv1</servlet-class>
</servlet>
+Pie Number of slices to send: Send
 

Originally posted by Kallol Das:

please ensure that <servlet-class> tag contains a valid relative path of the actual servlet class

That and the example are not correct. It is the fully-qualified class name of the servlet, not it's path, that is required.
+Pie Number of slices to send: Send
 

It is the fully-qualified class name of the servlet


Moreover, you are advised to put your servlets (like anything else) in packages. Don't put them directly under WEB-INF/classes, or you may get strange behaviours. Make some packages. Like "WEB-INF/classes/servlets"
+Pie Number of slices to send: Send
Satou,

Why is that we get Strange behaviors when we don't put our servlets in packages??
+Pie Number of slices to send: Send
For example, jsp:useBean does not work correctly with classes in the default package. So I think it's good practice to use packages. It's only an advice though
+Pie Number of slices to send: Send
Why do not you use

<url-pattern>/Ch1/Serv1</url-pattern>

instead of

<url-pattern>Ch1/Serv1</url-pattern>

in the web.xml and see what happens.
+Pie Number of slices to send: Send
 

Originally posted by Jothi Shankar Kumar Sankararaj:
Satou,

Why is that we get Strange behaviors when we don't put our servlets in packages??



Strange because you can get away with it for some types of objects but not others. There are specific reasons for this (explained here) but it's much simpler just to package everything than it is to understand all the reasoning that goes behind it.
+Pie Number of slices to send: Send
thanks for your valuable commands. I have solved my problem
Poop goes in a willow feeder. Wipe with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1708 times.
Similar Threads
404 Error
Servlet 404 error
Deployment Environment
HFSJ - The first servlet - I can't get it to work (SOLVED)
Directory Error
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 16:01:40.