Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why to use struts2.x

 
Nishita Jain
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I want to know that why should we use struts 2.x over struts1.x
I know what is the difference between these two but from that i couldn't found why we should use struts2.x
I felt that 2.x is bit hard to understand and interceptor concerns are very high in it.I feel it is more complex.

So pl help me out
Nishita
 
Joe Ess
Bartender
Posts: 9279
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have used Struts since it came out and recently picked up Struts 2. I think Struts 1 is easier to pick up, but it is less flexible. One ends up writing a lot of code to wedge business logic into the framework.
Struts 2 has a bit more of a learning curve, but it has more features. Unfortunately, because it's very flexible it is also hard to get a grasp as to where to start.
One big advantage for Struts 2 is that you don't have to override or implement an Action class. Just use a POJO. Less coding for the framework means you can be more productive on your app.
Struts 2 does away with the ActionForm so you can use the same data beans in your front end and your business logic. Again, less coding for the framework.
Interceptors aren't that big of a deal and they're really useful. Do you want session information in your action? Implement SessionAware. The session interceptor detects that interface and sets the session on your action. Need the servlet response, implement ServletResponseAware. Easy!
Interceptors are also useful to take care of the repetitive set-up code you write for several actions. I made a Hibernate interceptor to handle setting up all my data processing actions.
Don't like interceptors? You don't have to use them. One can get the session and response from the various context objects. I could have just as easily made a Hibernate base class and derive all my data processing actions from it. Again, the framework is really flexible.
I put all the links that helped me learn Struts 2 on our Struts FAQ Page.
 
Tejas Jain
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the biggest advantage of struts 2 over struts 1.x is that struts 2
supports RIA client (AJAX) much better through using DOJO.

There are a lots of architecture changes between struts 2 and 1, but not everyone likes the changes. In general, I do not like a framework that makes
a simple task harder.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic