• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why struts why not servlets?

 
Manjunath Chumbalakar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,

I am learning struts from last few days.What I get to know about struts is it's used for maintaining the MVC architecture.But we can use servlets for the same purpose. So why we need to go for struts? Whats special about struts? Please clarify this.
 
Joe Ess
Bartender
Pie
Posts: 9266
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Servlets have their place. I use them occasionally when I have some simple functionality I need to get done. However, if you write a couple of non-trivial applications, you'll probably find yourself following the Front Controller Pattern, where one servlet is configured to dispatch requests to some sort of handler. It is this pattern that Struts is modelled after. It has some other functionality, like form handling, validation, a tag library and so on. Basically, Struts takes care of the ugly details so you can focus more on getting your work done (which is true for most any framework, of course).
BTW, if you are just learning Struts, do yourself a favor and learn Struts 2. It fixes some of the big problems with the Struts 1.x series.
 
Manjunath Chumbalakar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks Joe.
 
Aleksey Serov
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The useful part of Servlet is the API between the web server (specifically the servlet container) and you application. This is the form the HTTP request is received in Java program and the HTTP response is provided by Java program. That includes access to Session too. Hardly it will go away any soon and all the (about 50) Java web frameworks including Struts 2 are build above that API. Programming just servlets may turn to be pretty low level, the frameworks each try to make web programming more clear and easy, each in its own way.
 
Manjunath Chumbalakar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks aleksey
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic