• 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

Solution for repeating function in all servlets.

 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi every body.

i have section of code(function) which is repeating in every servlet and in every servlet this function is called.


what can i do so that i donot need to write this function in every servlet and could use this function in every servlet .
Thanks and regards.
 
Ranch Hand
Posts: 689
Scala Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi,

There is no need to make this method because ultimately you just get requestdispatcher object and that you can put your every servlet doGet or doPost method.

So, put it into doGet or doPost or remove that method.

Or if you don't want to make servlet for every request and set request dispatcher then use Front controller patterns.

Struts use that patterns so if possible then use framework which use Front controller patterns. That makes your life easy.



 
rammie singh
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
but i need to forward the request to other pages also depending upon different conditions

so i guess if i don't use a function i will have to create request Dispatcher object each time i want to forward it to some page .....because i guess same request Dispatcher object can not be used again and again.

i hope i am clear to to you all guys.


here is my code.




 
Nishan Patel
Ranch Hand
Posts: 689
Scala Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi,

That's why I am telling you to use framework which use Fornt Controller Design patterns.

Like Struts and Spring ..... use of that framework will reduce your work and same thing you want to implement they have already implement in in.

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic