• Post Reply Bookmark Topic Watch Topic
  • New Topic

How add Servlet (i.e. bind to a url context/servlet-mapping) programmatically?

 
Dan Bizman
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a servlet filter that configures an application based on data in a properties file. What I want to be able to do is let the config file specify a class of a servlet (used as a hamdler for stuff) and the context to bind it to. Is this possible?

For example:

servlet.class=com.mycompany.MyServlet
servlet.mapping=/admin/users
servlet.name=handler

Then in the filter, it would bind this servlet to that servlet mapping.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65664
129
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like what you really need is a front controller.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lots of web frameworks implements, somewhat, the same thing. You can come up with something of your own using FrontController, as Bear already pointed out, and Command Pattern. Or you can use some existing framework, indeed, Like Spring, JSF, Struts etc.. Although, JSF is a component based framework and relatively different but interesting.
 
I can't take it! You are too smart for me! Here is the tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!