• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About invoke servlet.

 
Anna Wang
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, everyone,

From servlet specification, it said:
You can invoke a servlet by its class name.

I tried, but always got:
The requested resource (/myApp/Hello) is not available.

I did like this:

Write a servlet( for example: "Hello.java"), compile it, put Hello.class in WEB-INF/classes/, then
I invoke it by: http://localhost:8080/myApp/Hello

It doesn't work always.

Can anybody explain? Thanks.

Anna
 
Avinash Khushu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anna,
Did you create a <servlet> tag for the Hello Servlet in the web.xml file? If you have missed it, that may be the reason.

Thanks
Avinash
 
Anna Wang
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
About servlet tag means: I should write
<servlet>
<servlet-name> </servlet-name>
<servlet-class></servlet-class>
</servlet>

<servlet-mapping>
<servlet-name></servlet-name>
<url-pattern></url-pattern>
</servlet-mapping>

in web.xml?

I want to invoke the servlet just by its class name. I don't think I need write the servelt and servlet mapping. Am I right? Thanks
 
cheenu Dev
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any resource in the directory(or straight) under WEB-INF cannot be accesed by the clients. so you get that error.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic