Win a copy of Head First Android this week in the Android forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Servlet doubt

 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear All;

Can anybody tell me by using which method we can apply business logic in servlets...and syntax of that method...I asked this question in my interview so i was thinking about service()...but i think its wrong..

Anxiously, looking forward for your reply.

Thanking you in advance.

Thanks & Best Regards,
Brijesh Shah
 
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, without being able to clarify the question, I might guess that your interviewer was expecting you to name the doPost(HttpServletRequest req, HttpServletResponse resp) method in HttpServletRequest
HTTP post requests typically correspond to a request to process some data submitted by the user, perhaps some 'business' data.
 
Sheriff
Posts: 67595
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the interviewer is knoweledgable, the correct answer was "You don't do business logic in a servlet. You delegate it to a lower tier."
 
Brijesh shah
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It was subjective test in an interview in which they have specifically mentioned "By using which method you can apply business logic in the servlet and name that method"
 
Author
Posts: 3450
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An abiguous question. I would say that doGet() or doPost() method would delegate the business logic to the service tier (aka business logic layer).

May be the interviewer is trying to expect your answer of "No business logic in the servlet"
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if the application has no choice to implement business logic in different tier and it must be in the Servlet...According to my opinion, I think you were right, it might be in the service() method.

I always ask back interviewer if I can not answer his question. For that, I can learn new things(if any) or discuss if the question is not clear enough to answer ... or you did answer so well and the interviewer want you to get stuck (your car is running faster than his car)
[ June 13, 2007: Message edited by: Minh Tran ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Minh Tran:
if the application has no choice to implement business logic in different tier and it must be in the Servlet...According to my opinion, I think you were right, it might be in the service() method.



With the exception of a few rare cases, you should never override the service method. This method analyzes the request and delegates to either the doPost, doGet, or one of the other do... methods.

If Bear's answer did not satisfy the interviewer and you were pushed to name a specific method, arulk pillai's answer would have been perfect.
 
reply
    Bookmark Topic Watch Topic
  • New Topic