Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to call a servlet  RSS feed

 
Gaurav Chhabras
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have make a servlet and put in the package named coreservlets -:

C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\ROOT\WEB-INF\classes\coreservlets

I have compiled the servlet and the my servlet name is "servlet.java".

Now please tell me that how to call this servlet , or what is the right place to put servlet.

Please tell me the URL which i should write to call the servlet.

Regards
Gaurav
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the class is in the "coreservlets" package then it would go in:
C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\ROOT\WEB-INF\classes\coreservlets

You will now need to create a servlet entry and a servlet mapping in your deployment descriptor (web.xml).
You would invoke the servlet with the url-pattern from yoru servlet-mapping.


Here is an example web.xml file.
The servlet class name is SimpleServlet.
It's in the us.souther.simple package.
I've mapped it to the url pattern: simple-servlet
I would invoke it with the following URL (assuming the context name is "myapp"):
http://localhost:8080/myapp/simple-servlet

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!