File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes deployment descriptor question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "deployment descriptor question" Watch "deployment descriptor question" New topic

deployment descriptor question

ty lee

Joined: Dec 27, 2005
Posts: 5
Dear Sir: can i configure servlet in web.xml?
2.after configuration done,how can i trigger servlet in web browser?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

When you have to ask questions this basic, it means you really need to get some fundamental training; buy some books, take classes or something. Otherwise you'll spend your life asking the simple questions and people will get tired of answering.

At least you are headed in the right direction, so I'll give a general description.

Web.xml is the file that describes a WAR, and to make a servlet invokable, it usually takes 3 things:

1. A URL-to-logical servlet mapping

2. A logical-servlet-to-java-class mapping

3. A Servlet configuration

It could have been made simpler, but this way is more flexible. If I map the URL pattern "/info" to a logical servlet name "info-servlet", then map the logical servlet name "info-servlet" to an actual servlet class such as "com.javaranch.saloon.InfoServlet", then an HTTP request for "" would invoke the servlet.

Actually, the real URL might be more complicated, since the "/info" is added to a Servlet Context that defines the base URL. For our simple case, the base URL is "", but in a complex multi-app server environment running Tomcat, the base URL might be something like "", and you'd then invoke your servlet via the URL "".

Setting up the context (including base URL) is different for each appserver, so Tomcat, WebSphere and JBoss all have their own setups. But the stuff in web.xml remains the same.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: deployment descriptor question
jQuery in Action, 3rd edition