File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes servlet deployment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet deployment" Watch "servlet deployment" New topic
Author

servlet deployment

Lakshmi Priya
Greenhorn

Joined: Apr 24, 2007
Posts: 3
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
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

"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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Kallol Das
Greenhorn

Joined: Apr 24, 2007
Posts: 4
Could you show the web.xml page
Lakshmi Priya
Greenhorn

Joined: Apr 24, 2007
Posts: 3
<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
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

"_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 ]
Kallol Das
Greenhorn

Joined: Apr 24, 2007
Posts: 4
<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>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

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.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

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"


[My Blog]
All roads lead to JavaRanch
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9622
    
    2

Satou,

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


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

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
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
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.


Rahul Bhattacharjee
LinkedIn - Blog
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Lakshmi Priya
Greenhorn

Joined: Apr 24, 2007
Posts: 3
thanks for your valuable commands. I have solved my problem
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: servlet deployment