41
I need to get a few things cleared up. I have been looking for an answer for this one, but I can't seem to find a good answer to my specific questions (eg. this question was nibbling on the answer: Difference between servlet and web service).
To my understanding, there are different ways you can implement the "request handling", aka "Controller", in an "MVC oriented" web application, two of them being:
- A Java specific Servlet (ie. one you create by clicking new ->
Servlet, in eclipse for example), used as a "Controller". This one
extends
HttpServletand you use methods likedoGetanddoPostetc. - A Spring MVC annotated
@Controllerclass (yes, using aDispatcherServlet). With this one you use the@RequestMethodGET/POSTetc.
Now to my questions...
- When do you use one or the other?
- Are there any general advantages to use one method over the other? (Like, is one method recommended over the other in general?)
[EDIT]: Emphasized keywords