• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

About invoke servlet.  RSS feed

 
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
 
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
 
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
Boost this thread!