The advantage of Spring MVC is that once you've bootstrapped the application context and the database connection, it becomes incredibly easy to create new controllers and it follows a much more logic architecture that newer developers may actually find easier as they get more familiar with it.
Spring MVC, implements the Model View Controller (MVC) application pattern. And JSP, Java Server Pages, is a View technology. That is the way the framework serves views towards the client's browser.
Servlet: a server side java class to produce the html content. Spring: A framework to develop Big Enterprise Application which include your servlet as well.
If you're building a really quick and dirty demo that you have no intention of extending later, spring can result in a lot of additional configuration issues (not really if you've done it before, but I always end up fighting with it one way or another), so that might be a time to consider just using plain old servlets. Generally though, anything beyond just a super fast and dirty demo, using some form of MVC framework is going to make life in the future a lot easier and is also in line with best practices. Spring makes things super easy, just have to spend some time on the front end configuring everything.
I should note, there's nothing you can do with java servlets that you can't do with Spring. The big difference is setup time.
Edit: It's worth noting that when I posted this answer, I was unaware of Spring Boot that is actually quite easy to get up an running using either an embedded web server or a more conventional web container. Here's a link to a quick start example: http://projects.spring.io/spring-boot/#quick-start
Servlet technology is used for more generic server side extension for request-response paradigm. And Spring just uses it for the Web application over HTTP.
And some quote from here:http://www.reddit.com/r/java/comments/29f3ul/why_is_spring_mvc_better_than_servlets_jsp/
Servlets are based upon a low-level API for handling requests and responses. Web frameworks like Spring MVC are designed to make building web applications, which handle HTTP requests and responses, easier. Most Java web frameworks, including Spring MVC, use servlets behind the scenes.
You CAN use servlets to write a web application, but you'll have to handle all of the details manually. You'll get very little help with typical web stuff like validation, REST, request/response body for JSON, form binding, etc. You will end up writing lot of utility code to support your web application.
Web frameworks, on the other hand, are designed to make all of this stuff simple. With Spring MVC, you aren't bothered with manually handling the request and response even though you can still get access to them if you need to. Want to return JSON in Spring MVC? Just add a @ResponseBody annotation and Spring will append it. Want RESTful URLs? Easy. Input validation? Piece of cake. Want to bind form data to an object? Simple. With servlets, you'd have to do all of this stuff manually.
Using raw servlets can be a good learning experience though. It really helps to clarify how web frameworks make life easy for you!
I have developed projects both with raw servlet and web app framework. Framework gives you everything, only you need to is to setup and config the env, coding is much more easier. The result is that you will know nothing about web dev. However, code with raw api and servlet gives you chance to gain experience and be a programmer.
I don't use Spring a lot. But I don't see how would it have big impact on the performance. MVC's can help, but they can create a mess and extra work and frustration. The old good way is good enough for most projects implemented by one programmer. MVC's could help when there are more than one developer.
I would use a plain servlet/jsp for most projects. If I need reusable components, I use wicket. Servlets goes with JSPs/freemarker/velocity or other template engine for presentation.
If you follow a naming pattern for your Servlets/JSP, I don't think you need Spring MVC.
I find that, with the addition of Spring version 3+, it becomes much more easier to bootstrap a Spring Web application with all the basics. The advantage of Spring MVC is that once you've bootstrapped the application context and the database connection, it becomes incredibly easy to create new controllers and it follows a much more logic architecture that newer developers may actually find easier as they get more familiar with it.
In fact, at my previous place of work, we were in the process of building a Java Servlet Web application, but we found that we had to create our own architecture or spine of the application and that is actually more work. Spring can take care of that which means that developers can get on with the actually application logic instead of worrying about the architecture too much.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With