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..
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.
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 ]
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.