File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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

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?

Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 951

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.


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

Joined: Nov 24, 2005
Posts: 14688

And you should check the errata of the book, because this was written in it.

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

Joined: Mar 22, 2005
Posts: 42965
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?
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.
I agree. Here's the link:
subject: Why such web.xml and servlet invalid?
It's not a secret anymore!