• Post Reply Bookmark Topic Watch Topic
  • New Topic

Programmatically adding and configuring Servlets  RSS feed

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • 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,
 
Author and ninkuma
Marshal
Posts: 66352
155
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no standard way to do this. Various containers may provided proprietary interfaces.
 
Greenhorn
Posts: 12
Java jQuery Oracle
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!