This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi, I have a problem when I want to invoke servlet by name? I've simply mapped it in my web.xml. I can invoke it by class name or with any kind of mapping (Explicit mappings,Path prefix mappings,Extension mappings), but just to me, it won't by name. Here a simple which won't work at me:
Also, you should package all of your Java classes.
Your server might be able to find an un-packaged servlet but you will run into problems later (trying to locate bean classes from JSPs, for instance) if you continue using unpackaged Java classes in a web application.
Shouldn't I be able to invoke a servlet by registered name??? That is the question. I put my servlet in package, and I can make call to him by class name, or by (as I wrote) any sort of registered url (</url-pattern> . The reason why I put /index.html, is because of experimenting. But a problem is about invoking by registered name. I correct package name and still nothing...
Furthermore, I cannot at all invoke my servlet now (when I put it in the boby package)! The "boby" folder, with HelloWorld class is stored in "classes" folder, just as it should. But now I cannot call it neither by name, nor by class, nor by url--pattern. What is wrong now??? [ November 20, 2008: Message edited by: Slobodan Erakovic ]
Joined: Sep 26, 2008
No, really guys, I cannot inovke it at all... I registered it as :
then I try as :
without backslash, but it wont work... Neither with uri-pattern registration (either like : /hello.tml, /hello/*, or by extension!!) Nothing works!!! But, it stop working when I put it in the package so it must be a bad sort mapping....help....
There is nothing in the spec about being able to invoke a servlet by its name.
There was a period when containers had a mechanism to allow servlets to be invoked by a fully qualified class name for development and testing but, for security reasons, most containers have removed this feature. For Tomcat this was done with the InvokerServlet.