• 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
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

Programmatically adding and configuring Servlets

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I am relatively new to Java and have no experience in frameworks. I am trying to understand what it means to add/configure servlets/filters/listeners programmatically. Could somebody please give me a background of what it means, to get me started?

Your help is highly appreciated.

Thanks,
 
Sheriff
Posts: 67529
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
There is no standard way to do this. Various containers may provided proprietary interfaces.
 
Greenhorn
Posts: 12
jQuery Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you mean by add / configure servlets programmatically?
Are you mentioning about Eclipse / any IDE's wizard to create and manage servlets ?
if yes , all the wizard does is the web.xml [class path and servlet name] mapping work for you

Thanks
Alagesh
 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Anu Kota wrote:Hello,

I am relatively new to Java and have no experience in frameworks. I am trying to understand what it means to add/configure servlets/filters/listeners programmatically. Could somebody please give me a background of what it means, to get me started?

Your help is highly appreciated.

Thanks,



Hi,

Up to Servlet 3.0 specification, it was possible to define a servlet only in the Deployment Descriptor (web.xml).


Servlet 3.0 specification (section 4.4.1) defines programmatically ability to add a servlet to a context.
Seen from the API, it looks like this :



You can configure your servlet using the ServletRegistration object. This new feature gives you great flexibility, you can activate and configure
your servlets at runtime depending on different conditions that you are not aware of when you are creating your DD.

Greetings,
Liviu
 
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Note that this is not part of the SCWCD exam, which covers Servlet API 2.4, not Servlet API 3.0.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic