• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem accesing the servlet

 
rakesh kadulkar
Ranch Hand
Posts: 115
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello I am trying to access the servlet in WEB-INF\servlet folder directly using the servlet name only without using the DD .
The problem is solved using the DD but I want to know how to access without DD.

The servlet I have created is:


I am using tomcat 5.0.
The servlet is in the correct directory.
i.e webapps/example/WEB-INF/classes/servlet/HelloWorld.

On the browser I am entering

http://localhost:8080/example/servlet/HelloWorld
and I am getting error 404.

Help me.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64205
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No can do. You'll need to declare and map the servlet in the deployment descriptor. And the class file must be placed in the correct location.

Or, you can look up the deprecated Invoker -- but it's use is strongly discouraged.
 
rakesh kadulkar
Ranch Hand
Posts: 115
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok.
I wanted to try this because the "Java 2 complete reference " uses this as a first servlet example.
And the book says to access the servlet directly without using the DD.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64205
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I imagine that's a rather old reference...
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64205
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, I just looked it up. That book is from 2002. That's like reading a book on black and white televeisions to learn how to repair plasma flat screen TVs.

You really really need to use a much more modern reference.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please spell out abbreviations at least once in a message--I had *no* idea what you meant by DD.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13048
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read about the dread Invoker Servlet here.

Early versions of Tomcat thought it would be clever to give you a simple way to address a servlet by class name so they invented the "invoker" servlet. This was a VERY BAD IDEA - it makes it harder to move on to real world servlet applications.

"It seemed like the thing to do at the time"

Bill
 
Alex Pustovit
Greenhorn
Posts: 10
Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Actually you can't access any file within WEB-INF. I you wish to get access to your servlet you have to use deployment descriptor (DD) and address servlet-url defined there.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic