• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Configuring Servlets in web.xml

 
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If we have 100's of servlets in a web application , do we need to declare all of them in web.xml or is there any option for this ??
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to declare all your servlets. Some servers let you use the classname instead, but this is less user friendly and less secure.

Why do you have so many servlets? Most people have just one (or a few) controller servlets and control the rest via URLs.
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello RaviNada,

If you are using Tomcat, you can accomplish this via the Invoker Servlet (org.apache.catalina.servlets.InvokerServlet) in Tomcat's web.xml file. It allows you to execute servlet classes without needing to map them in web.xml.

However, in general this is not a good practice, since servlet mappings function to prevent users from accessing resources that they shouldn't have access to. Also, hundreds of servlets seems excessive! You may want to consider rolling functionality into fewer servlets, and when you do this, mapping becomes much more manageable.

Edwin

 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Edwin ,

what if the server is Weblogic ??Is there any option avialable like this ??
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want to limit the number of servlets to configure, use a Front Controller. If you want an easy-to-use implementation of one, check out my own Front Man package (follow link in my signature).

Avoid the invoker! Bad bad idea.
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks , nice solution
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Front controller is a good option
To be specific you can use struts framework
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rajat Raina wrote:Front controller is a good option
To be specific you can use struts framework


I think it´s a bit too late to introduce a MVC framework as he already has hundred servlets. You can better start off with a MVC framework from the zero on than applying it on an existing application, otherwise you´re going to waste a lot of time on changing.

A front controller is a better solution. I only hope that his servlets are well designed (thus not tight coupled with business and data logic) otherwise there is still a lot of rewrite needed.
reply
    Bookmark Topic Watch Topic
  • New Topic