• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Why such web.xml and servlet invalid?

 
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic