Struts 1.x vs Struts 2.x - java

I have reviewed a few Struts 1 vs 2 questions on SO but none seem to answer the question in the perspective that I am looking at it with.
I am about to start work architecting a new system, a complete re-engineering of a very old desktop application. The goal is to make it web based, add more functionality, make it more usable etc (the usual reengineering reasons).
The team who will be developing the system are mainly Java developers and have worked on Struts 1.x extensively over the past 5 years.
The system is intended to live for many years to come, so the idea of re-engineering again in 3-5 years time when a better framework comes out is not an option. It is not intended to heavily use AJAX.
My question, is why would I bother moving to Struts 2 when my team are so experienced with Struts 1.x. I understand that there are some improvements, but I worry that the time lost in getting the team up to speed, rework due to incorrect usage etc will far outweigh any benefit we would get from Struts 2. We like Struts 1, it does what we need to it do, and all the design patterns, standards, best practices etc are in place.
Are there any killer features with Struts 2 or serious problems I don't know about in Struts 1 that would sway the decision to stay with Struts 1.

If you are building a system from scratch I would definitely move onto version 2.x of Struts. The learning curve will not be great for a Struts 1.x team, but you will be able to take advantage of an up-to-date MVC framework.
For me the two main features of Struts 2.x which will enhance productivity are:
Built in AJAX support
No more ActionForms - you can bind directly into Domain Objects if you want, so this intermediate step has gone.
If it's a big project you're working on, you might want to look at a component framework e.g. JSF 2 or Wicket. If you're determined to stay on an Action based framework then I personally find Stripes a more productive framework.

Struts 1.x is 2000 vintage technology. Why on earth would you even consider sticking with it on a brand-new app?
The biggest drawback that I can see is that Struts locks you into a JSP-based, browser UI. Struts Actions are reusable only within the framework. You'll have a hard time seamlessly integrating a mobile device into that system if you need to.
I'd start thinking about web services, preferrably REST-based, and AJAX. The world has changed. I'd look into alternatives to Struts, like Spring or Play. Picking up a new web framework wouldn't be that big a deal, but the benefits could be worth it.
Those employees that have done nothing but work with an outdated framework for the last five years will thank you, too. Time for new skills.
UPDATE: If you've tried, and can't be late, and too many constraints, then I'd say you already know your answer. What are you hoping to get by coming here? I don't see an argument that you've failed to think through.

Given that your have a team with good experience in Struts 1.x and your product is stable as well, I don't see a great reason to migrate to Struts 2. Apache too seem to agree that http://struts.apache.org/roadmap.html#migrate_s1.

I'd think instead of asking "Stick with Struts1 or move to Struts2?" you'd better ask "Stick with Struts1 or move to a modern action based MVC web framework?". Why to move ? Because Struts1 is old and (frankly) sucks. Why not to move? Because we must learn a new framework. Granted, you know your resources, you must do the evaluation. But bear in mind that modern action based frameworks (Struts2, SpringMVC, Stripes) are quite easy to learn, and more so if your teams already knows Struts1.
Myself, I've have migrated from Struts to Struts2 and now I wouldn't like to return to Struts1 programming (those clumsy ActionForms!). I think Struts2 is much better. But one must also consider that Struts2 has also its weak points, the project does not seem very healty and the community does not seem very active.
The jump from Struts1 to Struts2 is not big, but is not as small as a version change ("Struts2" is a misnomer), and it is probably not smaller that the jump to SpringMVC, so I'd suggest to consider it (or Stripes).

More Generally, Struts 2.x layered framework compare to Struts 1.x. For example in data layer , Struts 2.x has DO layer between VO and DAO.. Similarly other features are mentioned in the below link..
http://struts.fromdev.com/2008/08/struts-1-vs-struts-2.html ..
Since your team has more experienced with struts 1.x , i don't think it will take more time to migrate your code in to struts 2.x.
Please be specific what kind of difference u are expecting..

in struts2.0 there are more feature and advantage , in struts2.0 there is no form beam,
a good and power full validation framework and most imported in struts2.0 for every request there is one instance of action but in sturts1.x only one instance of action for hole application.
so choice is yours . :)

Well the main reason is moving to struts 2.x in place of struts 1.x is
struts 1.x is in maintenance phase now not in much active development.
now when it starts with a team who have good understanding of struts 1.x is that they will get the underlying system quickly.but before let me to put one point in a clear manner.
struts1.x has no similarity with struts 2.x the only similarity is the name inherited from the parents.
struts2 has following advantages.
Action based framework
A strong Ajax support
Interceptors approach (core of framework)
4 Decoupled from the Serve let API which means plain POJO so unit testing will be much much easier
but my point is simple struts2 and struts1 only similar in terms of name but in terms of underlying architecture they are quite different.

Related

WHich is the best path or flow to learn java from web site perspective

I have just started learning java and i have about 8 months time. My main aim is to build web application using java. But as there are many java technologies/frameworks available i am conufused how should i go
IDE i am using is eclipse
The path which i am thinking is below
1)Learn Core Java
2)Project: Build Java Invoicing System with JDBC or mysql to test java knowledge
3)Learn Servlets / JSP to
4)Build small site like simple logon/memberarea/catalogue using servlets/jsp
Now guys I really don't know where the following things stand in my path and which things they will help
1)Java EE
2)Spring or spring MVC, what's the difference?
3)Hibernate
4)Wicket
5)Struts
I really don't know how should i learn those and which things to choose from.
what should be my final project which can be build using those because if i see from my current stage even website can be build using servlets/jsp. then why do i need those other technologies
Can anyone give an example of a project which can be build using new technologies and not using jsp/servlet, so that I can get an idea why we need those?
Lot's of stuff to learn in here so I would take it a bit at a time. I'm going to assume you are relatively comfortable with the Java language and core APIs.
First learn about JDBC and databases. Get a basic functional JDBC example app working (not visual just some a vanilla Java app) that does read/insert/update/delete of some records in a table. This will give you the basis for building whatever app you choose. Almost all interesting applications involve some sort of persistence/database.
Learn the main JDBC APIs (Connection, PreparedStatement, ResultSet) and write some code that uses these to get comfortable.
Learn about how transactions work in databases if you aren't familiar already and how JDBC uses them (Connection.commit and rollback)
Next you could look into the spring framework. This has a several useful features that come in handy when building these applications. The main ones to get to know the dependency injection functionality and the JDBC libraries it has. The DI stuff is a bit of a "duh"? if you haven't used it before but it is very useful/powerful especially for medium size + apps. The JDBC libraries help with the cruft of dealing with the raw JDBC APIs and make your code less error-prone.
Once you've got some basic JDBC and Spring stuff worked out you can then start bringing in a web framework.
This is more difficult because there are so many. In the interest of getting something up and running quickly I would probably go with Wicket. It runs inside a servlet container like Jetty, easy to get up and running with a basic web page or two and relatively easy to evolve of the project over time without going down too many blind alleys. I've found that frameworks like JSF (the Java EE default web/view framework) takes a lot of up front time investment to get going on. Most of these frameworks, including Wicket, can leverage the spring stuff you've got above.
Avoid JSP, it's unpleasent technology and outdated by virtually everything else.
To answer some of your other points.
Hibernate is a tool for mapping an object model to a relational model. In it's most basic form you define a Java class for each DB table with the class having one Java property (variable+getter+setter) for each DB column. You can also add references from one class to another to model database relations. It is good but it takes a bit of getting used to.
Spring I've explained partly above. Spring is much bigger than just DI and some JDBC libraries. It also has transaction management libs and bunch of other stuff. Spring MVC is a web framework which lives under the spring umbrella and makes use of a lot of the spring libraries internally. I've never used it so can't offer an opinion on it.
Java EE is an umbrella term for a large set of "enterprise" specifications/libraries. JSF is a web view framework that is part of Java EE.
That's my very high level advice. To summarise I would learn basic DB/JDBC then some spring stuff and then start building a basic web app using what you've learned already.
Hope that helps. There's plenty of info out there on the web on all these topics and you can always ask questions here on more specific parts if you need help. Good luck and enjoy!
EDIT (to address comment):
All of the above is my recommendation/opinion on how to approach learning Java web development.
In summary
Learning JDBC/transactions/databases is a must
Spring is optional but I strongly recommend. Spring is a big library but you can pick and choose the bits you like/need.
Web frameworks the choice is really yours. From what I have tried (JSF/JSP/Wicket) Wicket is the easiest to get going with so you don't spend too much time frustrated with the getting the initial setup. JSP is awful, it's very easy to make a mess with it. JSF is powerful but heavy and probably more suited to very enterprisy projects than a first web app.
Hibernate is optional but can make life easier simply because you can work with Java objects when you do DB queries/updates rather than writing tedious insert/update statements. Hibernate isn't the only tool like this but it's the one I've used most and does the job well. Just don't go too overboard with the "clever" hibernate features initially.
You could easily use Spring MVC instead of Wicket. That may be a perfectly good choice, I've not used Spring MVC myself so can't comment. I'm sure it will integrate well with spring stuff tho so that would certainly be a positive factor.
Do some more research if you're not sure, there's no end of people happy to give their opinion! But really you just have to dive in and try something.
You are correct. If all your applications are served by servlets, JSPs, and JDBC, then maybe you don't need to learn anything else.
I commend you for learning the fundamentals first before diving into a thicket of frameworks that you don't understand. That's a good thing.
But if you reach the point where you have those down cold, maybe looking at these other technologies can help you improve your game.
1)Java EE
You are learning (part) of Java EE when you use servlets, JSPs, and JDBC. They're a subset of the full Java EE machinery - EJBs, JMS, JNDI, etc.
2)Spring or spring MVC whats
difference
Spring is an alternative framework developed by Rod Johnson and Springsource, now part of VMWare, that is based on dependency injection, aspect-oriented programming, and framework modules. Spring web MVC is one module in the Spring framework, based on servlets, that acts as the front end for web applications.
3)Hibernate
An object-relational mapping technology (ORM), built on top of SQL and JDBC, that lets you map objects to tables. It has its own object-based query language.
4)Wicket
Another web MVC alternative to Spring MVC, Struts, JSF, etc.
5)Struts
The first web MVC framework. It's gone through versions 1.0 and 2.0, and has now been supplated by Java Server Faces. It's still used, though. Like all other web MVC frameworks in Java, it's based on servlets and JSPs.
From a Java perspective it might be best to start looking at Java EE. All the others you mentioned are alternative technologies, which might be useful to you if you decide that what the standard framework offers isn't your cup of tea. But for that to decide, it's never a bad idea to at least know what the standard framework is about.
Truth be told, before 2006 the standard framework had a bad reputation and some of the sentiments that form the basis for recommending alternative technologies are still based on that. Starting with version 5, Java EE got dramatically better. The latest version, Java EE 6 is arguably one of the best Java frameworks that's out there. Of course, the best is a highly subjective term and naturally it won't be the best one for each and every person out there.
At any length, Java EE 6 is a very complete framework that allows a large range of application to be written without depending on any additional library. Being the standard framework, most other frameworks at least depend on some parts of it.
Most typically EJB, CDI and JSF are replaced by alternative technologies. E.g. the core Spring container replaces EJB and CDI and Spring MVC replaces JSF. A full Spring stack typically still uses JPA, JTA, JMS and Servlet from Java EE. Wicket on its turn only replaces JSF, or when used with a Spring stack replaces Spring MVC.
Hibernate is a special case. It doesn't replace anything from Java EE, but is instead often used as an implementation for one of the key APIs of Java EE: JPA. The original creator of Hibernate, Gavin King, is one of the prime supporters of the Java EE framework and is in fact the spec lead of one of the most important parts of modern Java EE: CDI.
Wicket by itself is a very nice web framework, but in practice it isn't used as often as JSF. I won't go into the discussion whether Wicket or JSF is 'better' (this is mostly a religious battle anyway), but due to the popularity of JSF there are simply more people experienced with it and there is a large community offering many things for JSF like component libraries and extensions.
Struts has historically been completely replaced by JSF. The original creator or Struts, Craig Mcclanahan, was the one who started JSF as the successor of Struts. Nevertheless, Struts was once the absolute de-facto standard for web frameworks in Java. It's not often advised to be used for new projects, but till this day it's still used in a huge number of existing applications. So even though it's not really 'hot' to learn Struts anno 2011 knowledge of it may still be very practical for when you have to maintain existing applications.
ps
See this answer for a general description about Java EE: Frameworks for Layering reusable Architectures
I'm sure that nobody seriously can tell you the best way, because this would mean that (s)he would have tried all. Why do you want to learn a Java web application framework? Just to learn it to be prepared for the (next) job? In that case it is likely that you've learned the wrong one.
The next question would be what you want to do with the web application framework. Do you want to make a website a little bit active, e.g. make each page look similar (corporate design), auto-generate menus from an internal structure, or do you want to write a real web application, e.g. with database access.
I'd first define the goal what you want to achieve. IMHO a good way to motivate you to make it right is to take a small project which helps you to solve a small problem.
Then I would start with Java Server Pages (JSP) and servlets to understand the basic concepts. Then you can try to do the same with a few well-known web application frameworks, e.g. Wicket.

Which framework to choose nowadays, which would be still performant+able to do everything in it (pros & cons) [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Choosing a Java Web Framework now?
Hi All,
I'm thinking about which framework to choose for web applications. There are so many web frameworks and I'm afraid of trying all of them - it could be time consuming and I wouldn't have to found much with simple examples.
I have experience with jsp, jsf1.2, struts1. I can say I don't like pure jsp with tags. Struts1 again is quite similar to jsp in my view but a bit better. I do like jsf, I find it quite simple to use :), but I'm worried about performance. We used icefaces and lack of get support was really bad.
I know there exist other frameworks, like spring mvc - could be good? . grails, ruby on rails, wicket, gwt, struts2,jsf2
What I need, I'd like to have a versatile framework which doesn't restrict me and at the same time it's no problem to create features e.g: ajax.A bit easier to develop in but still fast I would be scared to sacrifice performance for ease of development.
I do not have any production experience with other frameworks I named.Do you have? Could you share it please? What would you use?
Thank you very much.
Any experience appreciated.
Here's my take:
I have experience with jsp, jsf1.2, struts1.
You have my condolences.
I can say I don't like pure jsp with
tags. Struts1 again is quite similar
to jsp in my view but a bit better. I
do like jsf, I find it quite simple to
use :), but I'm worried about
performance. We used icefaces and lack
of get support was really bad.
I don't care for JSF or Struts.x at all.
I know there exist other frameworks,
like spring mvc - could be good?
Yes, Spring is very good. It's much, much more than a web MVC framework as well. It's performant, it's got traction, it's got the financial backing of VMWare. I think it's the clear winner in the Java EE space.
. grails.
Grails is built on Spring and Hibernate.
, ruby on rails,
Not Java.
wicket,
Could be good. I have no experience with it.
gwt
Write Swing, turn it into JavaScript. I have no experience with it.
I think Spring is a clear winner. It's been on top for five years and hasn't lost a thing.
For a presentation layer framework: There is plenty to choose and I cannot really recommend one over another as I have only worked with one or two.
For a general framework to build your application, I recommend Spring. It is well known, support is ok and it is usually very easy to hook whatever specific-purpose framework you may want to use.
http://www.jodd.org/ seems to be a very good, fast and open framework that includes many facets needed for webapplications.
For the presentation layer, GWT with Uibinder could really match your demands :
you build your pages with xml
(pretty much like jsf/facelets)
it's designed to be fast
it's a google product, with a really
big community
it's really well integrated with
eclipse and easy to start using it

What's the best practice to start web programing in Java?

Jsp or struts ?
In fact I'm even not so clear about the difference of the two framework, or is Jsp a framework at all?
There's also Spring MVC.
Struts, Spring, Tapestry, etc. are MVC (Model-View-Controller) frameworks. JSP is just a presentation layer that is transformed to an HTML tags for display to browser.
Struts is the "grandfather" of MVC frameworks with huge followings. Struts2 is another. Spring is the now-generation of frameworks that includes Spring MVC for MVC as well as other goodies.
All these MVC's allows you to connect to a presentation layer such as JSP, HTML, FreeMarker, etc.
Hope this helps.
Struts is a dead vintage framework. Don't you mean Struts 2? Anyway, there is no "best practice". Just choose whatever framework suits your needs. JSP is no framework, it's a view technology. Almost all frameworks are built on top of JSP/Servlet. Only JSF 2.0 doesn't by default use JSP, but its successor Facelets.
Related questions
Java web development, what skills do I need?
What to learn for making Java web applications?
What's the difference between JSF, JSP and Servlet?
Choosing a Java web framework right now?
If you're just starting out, I'd recommend avoiding the complexity of frameworks.
I started out by learning about web architecture from Martin Fowler's book Patterns of Enterprise Application Architecture. I recommend that more than anything; it will change the way you think and allow you to understand why certain frameworks are the way they are.
The best part of hand-coding using these patterns was that I was never fighting a weird corner-case of a framework's API, and I knew exactly what my entire codebase was doing.
The worst part is that you have to write a lot of CRUD data access code by hand, but this practice will make persistence frameworks like Hibernate MUCH more comprehensible.
A description of all the patterns are available for free online, as well as some excellent papers:
http://martinfowler.com/eaaCatalog/
The thing is, if you buy the book you'll get the complete picture. You can buy it for $30 US here:
http://www.abebooks.com/servlet/SearchResults?sts=t&tn=patterns+of+enterprise+application+architecture&x=0&y=0
One thing I don't remember if he covers is connection pooling/management or the particulars of JDBC. Just remember: ThreadLocal is your friend. It's a good way to use a JDBC connection (and any other request-scoped variables) for the life of a request without having to pass Connections around all the time. You can add pooling later.
And one other thing: JUnit + Apache HTTP Commons + XMLUnit are INDISPENSIBLE for testing. Make sure you run system tests! They will change how you code (for the better). You can assert the input/output of HTTP requests and their responses. Sometimes it's too high-level, but you'll learn when to test at a finer granularity.
They work together. But I would recommend to learn JSP first.
However, you can check out this Struts overview as well. It should give you the big picture.
have you considered Google Web Toolkit?
I recommend trying out Apache Tapestry.
It is easy to get started (read: lacks a lot of XML configuration), easy to refactor due to the templates being closely tied to POJOs and the fact that is based on sensible conventions yet allows you to change these is a definite plus.
The two biggest quarrels I have with it are that it has stringly-typed #Validate annotations and searching for "tapestry" sometimes brings up a lot of information about tapestries.
There is a good tutorial over at http://tapestry.apache.org/tapestry5/tutorial1/index.html.

is struts a good starting point for java web

I've been developing in java then I stopped, so now since I have my google app engine account I wanted to start with this again. Also, I love web and I know struts is a good MVC framework.
I've been reading this. Do you think struts can help me to start or should I start with "plain" servlets, and then go to some framework?
I would at least learn the basic servlet lifecycle and API.
As Joel puts it abstractions are leaky and this applies to frameworks--all frameworks not just Web ones--equally well. You will be much better equipped to use a framework, to know why it's good and how it can help you if you understand the underlying technology, the thing it is trying to abstract.
As for Struts, I would steer clear of STruts 1. It's rather ancient now. There's still a lot of code around for it but I wouldn't consider it best practice now, particularly for its (over)use of inheritance. Struts 2 is really a completely different framework based on Webwork.
There are plenty of other MVC frameworks out there. Personally I like Spring MVC as being quite "pure" and lightweight.
I'd definitely start with an MVC framework as opposed to "plain" servlets as you suggest.
While I've used Struts 1.x a lot, I think for a new application you should look at Struts 2, Spring MVC or some other newer framework that leverage new Java features such as annotations.
I completely agree with cletus in the sense that I would start by completely understanding Servlet/JSP first.
After that, I would go to a more modern framework than Struts. To me, JSF or Spring sound like better options than Struts these days.
Struts 1 is now obsolete and Struts 2 doesn't seem to be getting much traction. There are lots of good frameworks out there, and you may want to consider instead: JSF, GWT, or Spring for example.
I suggest you to use Struts 1.x rather than Servlet, because this gives you lot of benefits like
PageNavigatin
Input validation
Extensibility
Modularity
I too agree in that learning fundamentals (Servlet API is a must, jsp/jstl highly recommended) first is the best thing to do. And for many simple things jsp/jstl combo is actually plenty good. But bigger the system, less maintainable such web apps tend to become. This is inverse of using heavy frameworks like JSF.
Beyond ones already suggested, I would recommend checking out Tapestry and Wicket: many developers like them. My experiences with JSF have been bit negative; but it's one of those love-or-hate frameworks, many swear by it, others just swear at it.

Best GUI framework for Java [duplicate]

This question already has answers here:
Closed 14 years ago.
I want to start a new project with Java;
In the past I used to start with Struts + Tiles; but tiles was very complicated; I don't know the latest version of Tiles;
I need your recommendations in details for a good GUI framework;
Thanks.
Duplicate of this question.
There is no "best" framework...
Indeed, "best" really depends on your needs, on your knwoledges (it can cost a lot of time to learn a new framework)...
At first when I read GUI framework I thought you meant Swing or SWT but I see you mention struts so I guess you mean presentation framework.
I agree that Tapestry is very good, but there are several others that are also quite good. Struts2, Stripes etc. Matt Raible has a very nice project going where he did all the initial integration work for several different technologies. It is quite easy to get up and running with struts+spring+hibernate or JSF or Tapestry and so on. He calls it AppFuse.
I use struts2 with spring and hibernate and sitemesh which was an AppFuse project to start with and it has served me well.
Stripes seems to be a great starting point for a Java web app too. I haven't used it as yet but I'm tempted.
I personally like Tapestry. I've only used version 4.1 but development time is way faster than JSP or JSF. It allows you to simply refresh pages to immediately see the changes you made without doing a deployment and uses actual HTML for the templates/pages so you can preview them without deploying any code at all. There is a little bit of a learning curve up front but its well worth it. Version 5.0 is in its final beta with a release candidate due out soon but I haven't tried it yet. It's also got pretty good and easy AJAX built in.

Categories