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 How to call a servlet from the browser ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to call a servlet from the browser ?" Watch "How to call a servlet from the browser ?" New topic
Author

How to call a servlet from the browser ?

Jorge Pinho
Greenhorn

Joined: May 16, 2003
Posts: 25

Hi all

I am following a very simple tutorial on servlets, it goes:

1 - code a class and compile it, it inherits from HttpServlet
(no pain here !!)

2 - Move the compiled class to /WEB-INF/classes
(kids class ah!!)

3 - restart tomcat
(I even re-started my PC several times, it�s tomcat 5.5)

4 - call: http://localhost:8080/myapp/MyServlet

I never get anything... always an error (The requested resource is not available).

The tutorial doesn�t say anything about the web.xml file. the index.jsp (with java code) works fine.

Is this the way to do things ? I have some experience with java but for the first time I am doing servlets, I wonder how so much trouble ???

Any help ???

Jorge

[ July 05, 2005: Message edited by: Jorge Pinho ]
[ July 05, 2005: Message edited by: Jorge Pinho ]

Jorge Pinho / SCJP 5
Live Help via Skype - lets.talk.about.help
Dont wait for forum answers
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61084
    
  66

Two things:

1) Make sure that your servlet is in a package other than the default.

2) You must add a servlet and a mapping declaration to your web.xml.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Jorge Pinho
Greenhorn

Joined: May 16, 2003
Posts: 25

...and there was light, it worked nicely on first try.

Thankx Bear
 
 
subject: How to call a servlet from the browser ?