Comparison of Four Popular Java Web Framework Implementations: Struts1.X, Webwork2.2X, Tapestry4, JSF1.2
Total Page:16
File Type:pdf, Size:1020Kb
Comparison of Four Popular Java Web Framework Implementations: Struts1.X, WebWork2.2X, Tapestry4, JSF1.2 Peng Wang University of Tampere Department of Computer Sciences Master’s thesis Supervisor: Roope Raisamo May 2008 i University of Tampere Department of Computer Sciences Peng Wang: Comparison of Java Web Framework: Struts1.X, WebWork2.2X, Tapestry4, JSF1.2 Master’s thesis, 101 pages May 2008 Java web framework has been widely used in industry Java web applications in the last few years, its outstanding MVC design concept and supported web features provide great benefits of standardizing application structure and reducing development time and effort. However, after years of evolution, numerous Java web frameworks have been invented with different focuses, it becomes increasingly difficult for developers to select a suitable framework for their web applications. In this thesis, we conduct a general comparison of four popular Java web frameworks: Struts1.X, WebWork2.2X, Tapestry 4, JSF1.2, and we try to help web developers or technique managers gain a deep insight of these frameworks through the comparison and therefore be able to choose the right framework for their web applications. The comparison preformed by this thesis generally takes three steps: first it studies the infrastructure of four chosen frameworks through which the overall view of different frameworks could be presented to readers; second it selects six basic but essential web features and fulfill the feature comparison by discussing different frameworks’ web feature implementation; third it presents a case study application to provide practical support of feature comparison. The thesis ends with an evaluation of pros and cons of different framework web features and a general suggestion of web application types that the four chosen Java web frameworks can effectively fit in. Key words and terms: Java web framework, MVC, web features, Struts1.X, WebWork2.2X, Tapestry 4, JSF1.2, feature comparison. ii Acknowledgement I would like to thank Professor Roope Raisamo and Professor Jyrki Nummenmaa for being my thesis tutor and examinator. Their patient, responsible attitude and meaningful advice help me steer clear of various serious mistakes and direct successfully my thesis to the final destination. With this chance I would also like to thanks my parents and my girlfriend Li Meng, their solicitude and encouragement is the foremost factor supporting me to finish this thesis. Tampere – Finland, June 2008 Peng Wang iii Contents 1. Introduction................................................................................................................1 2. Technology ................................................................................................................3 2.1. Technology used in Java web...........................................................................3 2.1.1 Java Servlet technology...........................................................................3 2.1.2 JavaServer Page.......................................................................................4 2.1.3 JavaBean component...............................................................................5 2.1.4 Enterprise JavaBeans (EJB) ....................................................................6 2.1.5 JavaServer Pages Standard Tag Library..................................................6 2.1.6 XML language.........................................................................................7 2.2 Introduction to MVC ...........................................................................................8 2.2.1 Traditional MVC become outdated.........................................................9 2.2.2 Web version MVC: Front Controller Pattern........................................10 2.2.3 Web version MVC involves: Page Controller Pattern ..........................12 2.3 Introduction to frameworks ...............................................................................12 2.3.1 They are the enhancement of JSP and Servlet API...............................12 2.3.2 Acting as MVC framework ...................................................................13 3. Infrastructure investigation......................................................................................15 3.1 Struts1.X ............................................................................................................15 3.1.1 Struts1.X components ...........................................................................17 3.1.2 Struts1.X workflow ...............................................................................20 3.2 WebWork2.2.X..................................................................................................21 3.2.1 WebWork key components ...................................................................24 3.2.2 WebWork2.2X workflow......................................................................27 3.3 Tapestry 4 ..........................................................................................................27 3.3.1 Tapestry 4 key components...................................................................29 3.3.2 Tapestry 4 workflow .............................................................................32 3.4 JSF1.2 ................................................................................................................34 3.4.1 JSF key components..............................................................................36 3.4.2 JSF workflow ........................................................................................37 3.5 Summary............................................................................................................39 4. Methodology............................................................................................................41 4.1. Feature comparison .................................................................................41 4.2 Case study and Conclusion of Java web frameworks ..............................42 4.3 Delimitations of the Method.....................................................................43 5. Web feature comparison ..........................................................................................44 5.1 Navigation rules.................................................................................................44 iv 5.1.1 Struts1.X................................................................................................44 5.1.2 WebWork2.2X ......................................................................................45 5.1.3 Tapestry 4..............................................................................................47 5.1.4 JSF 1.2...................................................................................................49 5.2 Validation mechanism .......................................................................................50 5.2.1 Struts1.X................................................................................................50 5.2.2 WebWork2.2X ......................................................................................52 5.2.3 Tapestry 4..............................................................................................55 5.2.4 JSF 1.2...................................................................................................58 5.3 Internationalization ............................................................................................59 5.3.1 Struts1.X................................................................................................60 5.3.2 WebWork2.2X ......................................................................................62 5.3.3 Tapestry 4..............................................................................................64 5.3.4 JSF 1.2...................................................................................................66 5.4 Type conversion.................................................................................................67 5.4.1 Struts1.X................................................................................................68 5.4.2 WebWork2.2X ......................................................................................70 5.4.3 Tapestry 4..............................................................................................72 5.4.4 JSF 1.2...................................................................................................73 5.5 IoC support ........................................................................................................75 5.5.1 Struts1.X................................................................................................75 5.5.2 WebWork2.2X ......................................................................................77 5.5.3 Tapestry 4..............................................................................................79 5.5.4 JSF 1.2...................................................................................................81 5.6 Post after Redirect..............................................................................................83 5.6.1 Struts1.X................................................................................................83 5.6.2 WebWork2.2X ......................................................................................85 5.6.3 Tapestry 4..............................................................................................87