This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Why such web.xml and servlet invalid? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Why such web.xml and servlet invalid?" Watch "Why such web.xml and servlet invalid?" New topic
Author

Why such web.xml and servlet invalid?

Zhixiong Pan
Ranch Hand

Joined: Jan 25, 2006
Posts: 239
Hi ranchers,

I am fresh here and now be trapped by a simple trouble.Please help me.
In my "SCWCDExamStudyKit" book's first example, the given web.xml file is as
and the servlet is as
With servlet compiled and located in the right place, the URL http://localhost:8080/chapter01/servlet/HelloWorldServlet still invalid. The tomcat I used is 5.0.28 while in the book version 4.0.1 is experimented. Is that the key point of my trouble? Could anyone give me some guide?


SCJP 1.4 SCJD
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
Hi,

In the latest version of tomcat the default servlet invoker application is disabled. so the link like host/app/servlet/servletName will not work. You have to change this setting manually in the tomcat. Better way to use the <servlet-mapping> component to map the servlet to url-pattern.

I think in the web.xml you have to modify the complete siganture of <web-app> element. There are xml components in <web-app ......> which give which version of Sevlet you are using.

Thanks


Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

And you should check the errata of the book, because this was written in it.
http://www.manning.com/deshmukh2/excerpt_errata.html

And my advice: Check all the tags in this book with the latest specification, because there are all for version 2.3 ! This, however, is not mentionned in the errata.

Good luck.


[My Blog]
All roads lead to JavaRanch
Zhixiong Pan
Ranch Hand

Joined: Jan 25, 2006
Posts: 239
Thank you all.

But trouble is remain. Being convinced of that <web-app> tag is lack of version info, I tried HelloWorldServlet in the servlets-examples package which run other servlet normally, and added a scope into web.xml under such package. And this time is still unfortunate. Is there any trouble with my HelloWorldServlet even if it was compiled well?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41155
    
  45
But trouble is remain.

Does that mean you added a servlet-mapping, and it still doesn't work? Then you could post the relevant web.xml excerpt.

Or did you enable the invoker?


Ping & DNS - my free Android networking tools app
Zhixiong Pan
Ranch Hand

Joined: Jan 25, 2006
Posts: 239
I have tried again. This time just put the HelloWorldServlet into a normal package and not modify the web.xml under such package, then OK. But the intention of the example to create a new package chapter01 and new web.xml still seems unreasonable.Cause with such package and web.xml, the HelloWorldServlet can run as expected.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Why such web.xml and servlet invalid?
 
Similar Threads
404 Error...need help
resource not available.
resource not available.
About executing servlet class
Stuck on HelloWorldServlet