File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Trying to test my first servlet. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Trying to test my first servlet." Watch "Trying to test my first servlet." New topic
Author

Trying to test my first servlet.

Susan Smith
Ranch Hand

Joined: Oct 13, 2007
Posts: 224
Hello,

I'm trying to test my first servlet. I use TOMCAT. I'm confused as how to call this servlet.
I put SampleServlet.java (below) under WEB-INF/classes
Then I compile the servlet. But then how do I call this servlet?

My servlet is like this:


Thanks in advance for all the help.
[ July 22, 2008: Message edited by: Susan Smith ]
Manuel Leiria
Ranch Hand

Joined: Jul 13, 2007
Posts: 171
You must also configure your servlet in web.xml file.


Manuel Leiria<br /> <br />--------------<br />Peace cannot be kept by force; it can only be achieved by understanding. <br /> Albert Einstein
Susan Smith
Ranch Hand

Joined: Oct 13, 2007
Posts: 224
Could you please give me some pointers as what to change/ add in the web.xml file?
Manuel Leiria
Ranch Hand

Joined: Jul 13, 2007
Posts: 171
Something like this:


So, you give the servlet a name (in this case sampleServlet) and tell the browser call the servlet when the url has /sampleservlet
Susan Smith
Ranch Hand

Joined: Oct 13, 2007
Posts: 224
It works great!
Thanks Manuel.
Manuel Leiria
Ranch Hand

Joined: Jul 13, 2007
Posts: 171
Originally posted by Susan Smith:
It works great!
Thanks Manuel.


Glad to help!

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Trying to test my first servlet.