• 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

About invoke servlet.

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic