This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doPost() and doGet()

 
Chris Brat
Ranch Hand
Posts: 108
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
is it 'correct' to define both the doGet() and doPost() methods in a servlet (as in programatically correct) in order to keep the number of servlets loaded to a minimum or would it be better to only implement one per servlet but have more servlets (in an attempt to simplify design?)...
Is this personal preference?
Thanks again.
 
Neeraj Singhal
Ranch Hand
Posts: 49
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chris
How does defining doGet() and doPost() affect the number of servlets loaded ??
it entirely depends on the requirement...whether u want to define doGet or doPost. BTW...u can define one and call it in another to achieve same functionality in both the methods.
[ September 30, 2003: Message edited by: Neeraj Singhal ]
 
Chris Brat
Ranch Hand
Posts: 108
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I meant that, I might choose to define only one of the methods per servlet thereby needing more classes to do the same functionality as i would need if i had declared both methods.
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"more classes to do the same functionality"
Well, that alone states that it would be a bad design of OOP principles. You want to keep functionality in one location and anyone that needs that functionality can call that one method. It is easier to maintain and enhance.
Sometimes you might want to consider pulling logic out into its own "helper class" that all Servlets can use and call.
Mark
 
Chris Brat
Ranch Hand
Posts: 108
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank u... that was what i was looking for.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic