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

Doubt Regarding Web.xml

Nittin singla

Joined: Jul 02, 2011
Posts: 24
Suppose i am working on some large application including thousands of servlets. Do i need to write each of these in the Deployment Descriptor file(Web.xml)?? Isnt there some shortcut to it?
Martyn Clark
Ranch Hand

Joined: Apr 16, 2005
Posts: 108
Which version of Servlets are you using if you use 3.0 you can configure mappings with annotations :-)

Martyn...<br /> <br />SCJP 1.4 SCWCD 1.4
Nittin singla

Joined: Jul 02, 2011
Posts: 24
No...I am using the older version...
elvadas nono

Joined: Jul 04, 2011
Posts: 12
Oups, I think with older version you should put all sevlet instances that the container should load in the deployment descriptors.
With servlet 3.0 API you can use Annotations, Web Fragments to reduce web.xml size,
you can also add servlet programmatically using new feartures of servletContext addServlet( String name, String class) etc..
Hussein Baghdadi
clojure forum advocate

Joined: Nov 08, 2003
Posts: 3479

A better solution could be using a MVC web framework like Struts2, Spring MVC, Stripes or FrontMan.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63865

Please read this article for information on a patter that can help.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Doubt Regarding Web.xml
It's not a secret anymore!