aspose file tools*
The moose likes Struts and the fly likes why struts why not servlets? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "why struts why not servlets?" Watch "why struts why not servlets?" New topic
Author

why struts why not servlets?

Manjunath Chumbalakar
Greenhorn

Joined: Feb 09, 2011
Posts: 7

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

Joined: Oct 29, 2001
Posts: 8927
    
    9

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Manjunath Chumbalakar
Greenhorn

Joined: Feb 09, 2011
Posts: 7

Thanks Joe.
Aleksey Serov
Ranch Hand

Joined: Sep 11, 2009
Posts: 32
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

Joined: Feb 09, 2011
Posts: 7
Thanks aleksey
 
 
subject: why struts why not servlets?