• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why such web.xml and servlet invalid?

 
Zhixiong Pan
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Zhixiong Pan
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic