Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

instantiating a servlet from another servlet

 
Ulvi Cetin
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a method in a servlet and want to invoke it form another. Any ideas how can this be done?

Thx.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That way lies grief. It'd be best to factor the common code out of the first servlet so that it can be more easily reused across multiple servlets. Probably the best way to do this would be to create an abstract servlet class containing the common code that both your servlets could extend.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic