Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlet deployment

 
Lakshmi Priya
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65220
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
 
Kallol Das
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you show the web.xml page
 
Lakshmi Priya
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<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
Pie
Posts: 65220
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"_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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<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
Pie
Posts: 65220
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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"
 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Satou,

Why is that we get Strange behaviors when we don't put our servlets in packages??
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Lakshmi Priya
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your valuable commands. I have solved my problem
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic