Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • 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
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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.
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!