SlideShare a Scribd company logo
Migrating from Struts 1 to Struts 2
 Matt Raible, Virtuas Open Source Solutions
 mraible@virtuas.com




                                              © 2005-2006, Virtuas Open Source Solutions
Introductions
Your experience with Java?
Your experience with Web Frameworks?
What do you hope to learn today?
Open Source experience: Ant, Struts, WebWork,
Spring, Hibernate, Eclipse, Tomcat?
Favorite IDE? Favorite OS? Favorite Server?
Matt
Raible
Web Framework Experience
 Struts: used since June 2001 - same time 1.0 was
 released.
 Spring MVC: used since January 2004 - before 1.0
 was released.
 WebWork: used since July 2004.
 Tapestry: used since July 2004.
 JSF: used since July 2004 - both Sun’s RI and
 MyFaces.
Agenda
1. Struts Overview
2. WebWork Overview
3. Reasons for Upgrading
4. Migrating from Struts 1 to Struts 2
5. Migrating from WebWork 2 to Struts 2
6. Pitfalls
7. Q and A
Struts 1.x Overview
Struts 1.x
Pros:
   The “Standard” - lots of Struts jobs
   Lots of information and examples
   HTML tag library is one of the best
Cons:
   ActionForms - they’re a pain
   Can’t unit test - StrutsTestCase only does
   integration
   Project has been rumored as “dead”
WebWork/Struts2
WebWork/Struts 2
Pros:
   Simple architecture - easy to extend
   Tag Library is easy to customize with
   FreeMarker or Velocity
   Interceptors are pretty slick
   Controller-based or page-based navigation
Cons:
   Small Community
   Documentation is poorly organized
WebWork / Struts 2
WW/S2 Lifecycle
WebWork Action
public class UserAction extends ActionSupport {
    private UserManager mgr;
    private User user;
    private String id;

   public void setUserManager(UserManager userManager) {
       this.mgr = userManager;
   }

   public void setId(String id) {
       this.id = id;
   }

   public User getUser() {
       return user;
   }

   public String edit() {
       // check for an add
       if (id != null) {
           user = mgr.getUser(id);
       } else {
           user = new User();
       }
       return SUCCESS;
   }
WebWork Interceptors
public class ValidationInterceptor extends AroundInterceptor {

    protected void after(ActionInvocation dispatcher, String result) throws Exception {
    }

    protected void before(ActionInvocation invocation) throws Exception {
        Action action = invocation.getAction();
        String context = invocation.getProxy().getActionName();

        final Map parameters = ActionContext.getContext().getParameters();
        // don't validate on cancel, delete or GET
        if (ServletActionContext.getRequest().getMethod().equals(quot;GETquot;)) {
            log.debug(quot;Cancelling validation, detected GET requestquot;);
        } else if (parameters.containsKey(quot;cancelquot;) || parameters.containsKey(quot;deletequot;)) {
            log.debug(quot;Cancelling validation, detected clicking cancel or deletequot;);
        } else {
            ActionValidatorManager.validate(action, context);
        }
    }
}
xwork.xml
<!-- List of Users -->
<action name=quot;usersquot; class=quot;userActionquot; method=quot;listquot;>
    <result name=quot;successquot;>userList.jsp</result>
    <result name=quot;inputquot;>userList.jsp</result>
</action>

<!-- Edit User -->
<action name=quot;editUserquot; class=quot;userActionquot; method=quot;editquot;>
    <result name=quot;successquot;>userForm.jsp</result>
    <result name=quot;inputquot;>userList.jsp</result>
</action>

<!-- Save User -->
<action name=quot;saveUserquot; class=quot;userActionquot;>
    <result name=quot;cancelquot; type=quot;redirectquot;>users.html</result>
    <result name=quot;deletequot; type=quot;redirectquot;>users.html</result>
    <result name=quot;inputquot;>userForm.jsp</result>
    <result name=quot;successquot; type=quot;chainquot;>saveUserWithValidation</result>
</action>
WebWork JSP View

<ww:form name=quot;userFormquot; action=quot;saveUserquot; method=quot;postquot; validate=quot;truequot;>
    <ww:hidden name=quot;user.idquot; value=quot;%{user.id}quot;/>

    <ww:textfield label=quot;%{getText('user.firstName')}quot; name=quot;user.firstNamequot;
        value=quot;%{user.firstName}quot; id=quot;user.firstNamequot;/>

    <ww:textfield label=quot;%{getText('user.lastName')}quot; name=quot;user.lastNamequot;
        value=quot;%{user.lastName}quot; required=quot;truequot;/>

    <ww:datepicker label=quot;%{getText('user.birthday')}quot; name=quot;user.birthdayquot;
        size=quot;11quot;/>
WebWork DatePicker

<ww:form name=quot;userFormquot; action=quot;saveUserquot; method=quot;postquot; validate=quot;truequot;>
    <ww:hidden name=quot;user.idquot; value=quot;%{user.id}quot;/>

   <ww:textfield label=quot;%{getText('user.firstName')}quot; name=quot;user.firstNamequot;
       value=quot;%{user.firstName}quot; id=quot;user.firstNamequot;/>

   <ww:textfield label=quot;%{getText('user.lastName')}quot; name=quot;user.lastNamequot;
       value=quot;%{user.lastName}quot; required=quot;truequot;/>

    <ww:datepicker label=quot;%{getText('user.birthday')}quot; name=quot;user.birthdayquot;
        size=quot;11quot;/>
Page-based Navigation

<%@ include file=quot;/common/taglibs.jspquot;%>

<h2>Author Blogs</h2>

<ww:action name=quot;authorsquot; id=quot;%{authors}quot; namespace=quot;defaultquot;/>

<div class=quot;itemquot;>
    <ww:iterator value=quot;#authors.authorsquot; status=quot;indexquot;>
        <a href=quot;<ww:property value=quot;blog.feedUrlquot;/>quot;>
            <img src=quot;${ctxPath}/images/icons/xml.gifquot; alt=quot;XML Feedquot;/></a>
        <a href=quot;<ww:property value=quot;blog.urlquot;/>quot;><ww:property value=quot;namequot;/></a>
        <br />
    </ww:iterator>
</div>
OGNL
<ww:form name=quot;userFormquot; action=quot;saveUserquot; method=quot;postquot; validate=quot;truequot;>
    <ww:hidden name=quot;user.idquot; value=quot;%{user.id}quot;/>

    <ww:textfield label=quot;%{getText('user.firstName')}quot; name=quot;user.firstNamequot;
        value=quot;%{user.firstName}quot; id=quot;user.firstNamequot;/>

    <ww:textfield label=quot;%{getText('user.lastName')}quot; name=quot;user.lastNamequot;
         value=quot;%{user.lastName}quot; required=quot;truequot;/>
</tr>
    <th><label for=quot;user.birthdayquot;><fmt:message key=quot;user.birthdayquot;/>:</label></th>
    <td>
         <ww:set name=quot;birthdayquot; scope=quot;requestquot;
             value=quot;(user.birthday instanceof java.util.Date) ? user.birthday : ''quot;/>
         <input type=quot;textquot; size=quot;11quot; name=quot;user.birthdayquot; id=quot;user.birthdayquot;
             value=quot;<fmt:formatDate value=quot;${birthday}quot; pattern=quot;${datePattern}quot;/>quot;/>
             [${datePattern}]
    </td>
<tr>
Struts 1   Struts 2
Comparison
    Struts 1             Struts 2

    Action                Action

  ActionForm         Action or POJO

 ActionForward            Result

struts-config.xml        struts.xml

 ActionServlet       FilterDispatcher

RequestProcessor       Interceptors

 validation.xml    Action-validation.xml
Features only in Struts 2
Page-based Navigation
Built-in Ajax Support: DWR and Dojo
Spring as default inversion of control container
Changed from front-controller servlet to filter
Much better client-side validation support
QuickStart and Annotations
JSF Support
Built-in support for testing with StrutsTestCase
Struts Plugins
Run Struts 1.x Actions
<action name=quot;editGangsterquot;
   class=quot;org.apache.struts2.s1.Struts1Actionquot;>
  <param name=quot;classNamequot;>
     com.mycompany.gangstas.EditGangsterAction
  </param>
  <result>
     gangsterForm.jsp
  </result>
</action>
Equinox
AppFuse Light - designed for quick apps with few
requirements (i.e. prototypes)
Includes 6 MVC implementations: JSF, Spring MVC,
Struts 1, Struts 2, Tapestry and WebWork
Includes 5 Persistence frameworks: Hibernate,
iBATIS, JDO, OJB, Spring JDBC
50 combinations available!
Located at http://equinox.dev.java.net
Sample Migration
WebWork 2   Struts 2
Comparison
        WebWork 2                      Struts 2

 com.opensymphony.xwork.*    com.opensymphony.xwork2.*

com.opensymphony.webwork.*       org.apache.struts2.*

        xwork.xml                     struts.xml

    webwork.properties             struts.properties

         <ww:*/>                        <s:*/>
Sample Migration
Pitfalls and Issues
Learn more from...
Don Brown's Struts 2.0 presentation/article:
    http://us.apachecon.com/presentations/WE9/WE9-
    struts-2.0.ppt
    http://www.oreillynet.com/onjava/blog/2006/10/
    my_history_of_struts_2.html
InfoQ's Migrating to Struts 2 articles:
    http://infoq.com/articles/converting-struts-2-part1
    http://infoq.com/news/struts2-migration-part2
Questions?
Struts Project:
    http://struts.apache.org
Community:
    http://struts.apache.org/mail.html
Tutorials:
    http://cwiki.apache.org/confluence/display/
    WW/Tutorials
Kickstart your development with Equinox:
    https://equinox.dev.java.net

More Related Content

What's hot

Express JS
Express JSExpress JS
Express JS
Alok Guha
 
Prometheus and Docker (Docker Galway, November 2015)
Prometheus and Docker (Docker Galway, November 2015)Prometheus and Docker (Docker Galway, November 2015)
Prometheus and Docker (Docker Galway, November 2015)
Brian Brazil
 
Azure Resource Manager (ARM) Templates
Azure Resource Manager (ARM) TemplatesAzure Resource Manager (ARM) Templates
Azure Resource Manager (ARM) Templates
WinWire Technologies Inc
 
Terraform in deployment pipeline
Terraform in deployment pipelineTerraform in deployment pipeline
Terraform in deployment pipeline
Anton Babenko
 
Introduce to Terraform
Introduce to TerraformIntroduce to Terraform
Introduce to Terraform
Samsung Electronics
 
Angular introduction students
Angular introduction studentsAngular introduction students
Angular introduction students
Christian John Felix
 
Helm 3
Helm 3Helm 3
Microservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring CloudMicroservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring Cloud
Eberhard Wolff
 
Prometheus design and philosophy
Prometheus design and philosophy   Prometheus design and philosophy
Prometheus design and philosophy
Docker, Inc.
 
Introducing AWS Elastic Beanstalk
Introducing AWS Elastic BeanstalkIntroducing AWS Elastic Beanstalk
Introducing AWS Elastic Beanstalk
Amazon Web Services
 
LOG4J
LOG4JLOG4J
Terraform: An Overview & Introduction
Terraform: An Overview & IntroductionTerraform: An Overview & Introduction
Terraform: An Overview & Introduction
Lee Trout
 
RESTful API - Best Practices
RESTful API - Best PracticesRESTful API - Best Practices
RESTful API - Best Practices
Tricode (part of Dept)
 
AWS Elastic Beanstalk
AWS Elastic BeanstalkAWS Elastic Beanstalk
AWS Elastic Beanstalk
Amazon Web Services
 
Advanced angular
Advanced angularAdvanced angular
Advanced angular
Sumit Kumar Rakshit
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API
07.pallav
 
Springboot Microservices
Springboot MicroservicesSpringboot Microservices
Springboot Microservices
NexThoughts Technologies
 
Being Functional on Reactive Streams with Spring Reactor
Being Functional on Reactive Streams with Spring ReactorBeing Functional on Reactive Streams with Spring Reactor
Being Functional on Reactive Streams with Spring Reactor
Max Huang
 
인프라 자동 배포를 위한 AWS CloudFormation 고급 활용법 - AWS Summit Seoul 2017
인프라 자동 배포를 위한 AWS CloudFormation 고급 활용법 - AWS Summit Seoul 2017인프라 자동 배포를 위한 AWS CloudFormation 고급 활용법 - AWS Summit Seoul 2017
인프라 자동 배포를 위한 AWS CloudFormation 고급 활용법 - AWS Summit Seoul 2017
Amazon Web Services Korea
 

What's hot (20)

Express JS
Express JSExpress JS
Express JS
 
Prometheus and Docker (Docker Galway, November 2015)
Prometheus and Docker (Docker Galway, November 2015)Prometheus and Docker (Docker Galway, November 2015)
Prometheus and Docker (Docker Galway, November 2015)
 
Azure Resource Manager (ARM) Templates
Azure Resource Manager (ARM) TemplatesAzure Resource Manager (ARM) Templates
Azure Resource Manager (ARM) Templates
 
Terraform in deployment pipeline
Terraform in deployment pipelineTerraform in deployment pipeline
Terraform in deployment pipeline
 
Introduce to Terraform
Introduce to TerraformIntroduce to Terraform
Introduce to Terraform
 
Angular introduction students
Angular introduction studentsAngular introduction students
Angular introduction students
 
Helm 3
Helm 3Helm 3
Helm 3
 
Microservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring CloudMicroservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring Cloud
 
Prometheus design and philosophy
Prometheus design and philosophy   Prometheus design and philosophy
Prometheus design and philosophy
 
Introducing AWS Elastic Beanstalk
Introducing AWS Elastic BeanstalkIntroducing AWS Elastic Beanstalk
Introducing AWS Elastic Beanstalk
 
LOG4J
LOG4JLOG4J
LOG4J
 
Terraform: An Overview & Introduction
Terraform: An Overview & IntroductionTerraform: An Overview & Introduction
Terraform: An Overview & Introduction
 
RESTful API - Best Practices
RESTful API - Best PracticesRESTful API - Best Practices
RESTful API - Best Practices
 
AWS Elastic Beanstalk
AWS Elastic BeanstalkAWS Elastic Beanstalk
AWS Elastic Beanstalk
 
Advanced angular
Advanced angularAdvanced angular
Advanced angular
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API
 
Springboot Microservices
Springboot MicroservicesSpringboot Microservices
Springboot Microservices
 
Terraform
TerraformTerraform
Terraform
 
Being Functional on Reactive Streams with Spring Reactor
Being Functional on Reactive Streams with Spring ReactorBeing Functional on Reactive Streams with Spring Reactor
Being Functional on Reactive Streams with Spring Reactor
 
인프라 자동 배포를 위한 AWS CloudFormation 고급 활용법 - AWS Summit Seoul 2017
인프라 자동 배포를 위한 AWS CloudFormation 고급 활용법 - AWS Summit Seoul 2017인프라 자동 배포를 위한 AWS CloudFormation 고급 활용법 - AWS Summit Seoul 2017
인프라 자동 배포를 위한 AWS CloudFormation 고급 활용법 - AWS Summit Seoul 2017
 

Similar to Migrating from Struts 1 to Struts 2

[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)Carles Farré
 
What's Coming in Spring 3.0
What's Coming in Spring 3.0What's Coming in Spring 3.0
What's Coming in Spring 3.0
Matt Raible
 
Strutsjspservlet
Strutsjspservlet Strutsjspservlet
Strutsjspservlet
Sagar Nakul
 
Struts,Jsp,Servlet
Struts,Jsp,ServletStruts,Jsp,Servlet
Struts,Jsp,Servlet
dasguptahirak
 
Strutsjspservlet
Strutsjspservlet Strutsjspservlet
Strutsjspservlet Sagar Nakul
 
Introducing Struts 2
Introducing Struts 2Introducing Struts 2
Introducing Struts 2
wiradikusuma
 
Retrofitting
RetrofittingRetrofitting
Retrofitting
Ted Husted
 
Strut2-Spring-Hibernate
Strut2-Spring-HibernateStrut2-Spring-Hibernate
Strut2-Spring-HibernateJay Shah
 
DWR, Hibernate and Dojo.E - A Tutorial
DWR, Hibernate and Dojo.E - A TutorialDWR, Hibernate and Dojo.E - A Tutorial
DWR, Hibernate and Dojo.E - A Tutorial
jbarciauskas
 
What's new and exciting with JSF 2.0
What's new and exciting with JSF 2.0What's new and exciting with JSF 2.0
What's new and exciting with JSF 2.0
Michael Fons
 
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group PresentationActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentation
ipolevoy
 
Introduction to JSF
Introduction toJSFIntroduction toJSF
Introduction to JSF
SoftServe
 
Struts2.0basic
Struts2.0basicStruts2.0basic
Struts2.0basic
­Avishek A
 
Struts2
Struts2Struts2
Struts2
yuvalb
 
Struts 2 + Spring
Struts 2 + SpringStruts 2 + Spring
Struts 2 + Spring
Bryan Hsueh
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
yuvalb
 

Similar to Migrating from Struts 1 to Struts 2 (20)

[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
 
What's Coming in Spring 3.0
What's Coming in Spring 3.0What's Coming in Spring 3.0
What's Coming in Spring 3.0
 
Strutsjspservlet
Strutsjspservlet Strutsjspservlet
Strutsjspservlet
 
Struts,Jsp,Servlet
Struts,Jsp,ServletStruts,Jsp,Servlet
Struts,Jsp,Servlet
 
Strutsjspservlet
Strutsjspservlet Strutsjspservlet
Strutsjspservlet
 
Introducing Struts 2
Introducing Struts 2Introducing Struts 2
Introducing Struts 2
 
Retrofitting
RetrofittingRetrofitting
Retrofitting
 
Strut2-Spring-Hibernate
Strut2-Spring-HibernateStrut2-Spring-Hibernate
Strut2-Spring-Hibernate
 
Spine.js
Spine.jsSpine.js
Spine.js
 
DWR, Hibernate and Dojo.E - A Tutorial
DWR, Hibernate and Dojo.E - A TutorialDWR, Hibernate and Dojo.E - A Tutorial
DWR, Hibernate and Dojo.E - A Tutorial
 
Jsfsunum
JsfsunumJsfsunum
Jsfsunum
 
Struts Overview
Struts OverviewStruts Overview
Struts Overview
 
What's new and exciting with JSF 2.0
What's new and exciting with JSF 2.0What's new and exciting with JSF 2.0
What's new and exciting with JSF 2.0
 
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group PresentationActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentation
 
Introduction to JSF
Introduction toJSFIntroduction toJSF
Introduction to JSF
 
Struts2.0basic
Struts2.0basicStruts2.0basic
Struts2.0basic
 
Unit 07: Design Patterns and Frameworks (3/3)
Unit 07: Design Patterns and Frameworks (3/3)Unit 07: Design Patterns and Frameworks (3/3)
Unit 07: Design Patterns and Frameworks (3/3)
 
Struts2
Struts2Struts2
Struts2
 
Struts 2 + Spring
Struts 2 + SpringStruts 2 + Spring
Struts 2 + Spring
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 

More from Matt Raible

Keep Identities in Sync the SCIMple Way - ApacheCon NA 2022
Keep Identities in Sync the SCIMple Way - ApacheCon NA 2022Keep Identities in Sync the SCIMple Way - ApacheCon NA 2022
Keep Identities in Sync the SCIMple Way - ApacheCon NA 2022
Matt Raible
 
Micro Frontends for Java Microservices - Belfast JUG 2022
Micro Frontends for Java Microservices - Belfast JUG 2022Micro Frontends for Java Microservices - Belfast JUG 2022
Micro Frontends for Java Microservices - Belfast JUG 2022
Matt Raible
 
Micro Frontends for Java Microservices - Dublin JUG 2022
Micro Frontends for Java Microservices - Dublin JUG 2022Micro Frontends for Java Microservices - Dublin JUG 2022
Micro Frontends for Java Microservices - Dublin JUG 2022
Matt Raible
 
Micro Frontends for Java Microservices - Cork JUG 2022
Micro Frontends for Java Microservices - Cork JUG 2022Micro Frontends for Java Microservices - Cork JUG 2022
Micro Frontends for Java Microservices - Cork JUG 2022
Matt Raible
 
Comparing Native Java REST API Frameworks - Seattle JUG 2022
Comparing Native Java REST API Frameworks - Seattle JUG 2022Comparing Native Java REST API Frameworks - Seattle JUG 2022
Comparing Native Java REST API Frameworks - Seattle JUG 2022
Matt Raible
 
Reactive Java Microservices with Spring Boot and JHipster - Spring I/O 2022
Reactive Java Microservices with Spring Boot and JHipster - Spring I/O 2022Reactive Java Microservices with Spring Boot and JHipster - Spring I/O 2022
Reactive Java Microservices with Spring Boot and JHipster - Spring I/O 2022
Matt Raible
 
Comparing Native Java REST API Frameworks - Devoxx France 2022
Comparing Native Java REST API Frameworks - Devoxx France 2022Comparing Native Java REST API Frameworks - Devoxx France 2022
Comparing Native Java REST API Frameworks - Devoxx France 2022
Matt Raible
 
Lock That Sh*t Down! Auth Security Patterns for Apps, APIs, and Infra - Devne...
Lock That Sh*t Down! Auth Security Patterns for Apps, APIs, and Infra - Devne...Lock That Sh*t Down! Auth Security Patterns for Apps, APIs, and Infra - Devne...
Lock That Sh*t Down! Auth Security Patterns for Apps, APIs, and Infra - Devne...
Matt Raible
 
Native Java with Spring Boot and JHipster - Garden State JUG 2021
Native Java with Spring Boot and JHipster - Garden State JUG 2021Native Java with Spring Boot and JHipster - Garden State JUG 2021
Native Java with Spring Boot and JHipster - Garden State JUG 2021
Matt Raible
 
Java REST API Framework Comparison - PWX 2021
Java REST API Framework Comparison - PWX 2021Java REST API Framework Comparison - PWX 2021
Java REST API Framework Comparison - PWX 2021
Matt Raible
 
Web App Security for Java Developers - PWX 2021
Web App Security for Java Developers - PWX 2021Web App Security for Java Developers - PWX 2021
Web App Security for Java Developers - PWX 2021
Matt Raible
 
Mobile App Development with Ionic, React Native, and JHipster - Connect.Tech ...
Mobile App Development with Ionic, React Native, and JHipster - Connect.Tech ...Mobile App Development with Ionic, React Native, and JHipster - Connect.Tech ...
Mobile App Development with Ionic, React Native, and JHipster - Connect.Tech ...
Matt Raible
 
Lock That Shit Down! Auth Security Patterns for Apps, APIs, and Infra - Joker...
Lock That Shit Down! Auth Security Patterns for Apps, APIs, and Infra - Joker...Lock That Shit Down! Auth Security Patterns for Apps, APIs, and Infra - Joker...
Lock That Shit Down! Auth Security Patterns for Apps, APIs, and Infra - Joker...
Matt Raible
 
Web App Security for Java Developers - UberConf 2021
Web App Security for Java Developers - UberConf 2021Web App Security for Java Developers - UberConf 2021
Web App Security for Java Developers - UberConf 2021
Matt Raible
 
Java REST API Framework Comparison - UberConf 2021
Java REST API Framework Comparison - UberConf 2021Java REST API Framework Comparison - UberConf 2021
Java REST API Framework Comparison - UberConf 2021
Matt Raible
 
Native Java with Spring Boot and JHipster - SF JUG 2021
Native Java with Spring Boot and JHipster - SF JUG 2021Native Java with Spring Boot and JHipster - SF JUG 2021
Native Java with Spring Boot and JHipster - SF JUG 2021
Matt Raible
 
Lock That Shit Down! Auth Security Patterns for Apps, APIs, and Infra - Sprin...
Lock That Shit Down! Auth Security Patterns for Apps, APIs, and Infra - Sprin...Lock That Shit Down! Auth Security Patterns for Apps, APIs, and Infra - Sprin...
Lock That Shit Down! Auth Security Patterns for Apps, APIs, and Infra - Sprin...
Matt Raible
 
Reactive Java Microservices with Spring Boot and JHipster - Denver JUG 2021
Reactive Java Microservices with Spring Boot and JHipster - Denver JUG 2021Reactive Java Microservices with Spring Boot and JHipster - Denver JUG 2021
Reactive Java Microservices with Spring Boot and JHipster - Denver JUG 2021
Matt Raible
 
Get Hip with JHipster - Colorado Springs Open Source User Group 2021
Get Hip with JHipster - Colorado Springs Open Source User Group 2021Get Hip with JHipster - Colorado Springs Open Source User Group 2021
Get Hip with JHipster - Colorado Springs Open Source User Group 2021
Matt Raible
 
JHipster and Okta - JHipster Virtual Meetup December 2020
JHipster and Okta - JHipster Virtual Meetup December 2020JHipster and Okta - JHipster Virtual Meetup December 2020
JHipster and Okta - JHipster Virtual Meetup December 2020
Matt Raible
 

More from Matt Raible (20)

Keep Identities in Sync the SCIMple Way - ApacheCon NA 2022
Keep Identities in Sync the SCIMple Way - ApacheCon NA 2022Keep Identities in Sync the SCIMple Way - ApacheCon NA 2022
Keep Identities in Sync the SCIMple Way - ApacheCon NA 2022
 
Micro Frontends for Java Microservices - Belfast JUG 2022
Micro Frontends for Java Microservices - Belfast JUG 2022Micro Frontends for Java Microservices - Belfast JUG 2022
Micro Frontends for Java Microservices - Belfast JUG 2022
 
Micro Frontends for Java Microservices - Dublin JUG 2022
Micro Frontends for Java Microservices - Dublin JUG 2022Micro Frontends for Java Microservices - Dublin JUG 2022
Micro Frontends for Java Microservices - Dublin JUG 2022
 
Micro Frontends for Java Microservices - Cork JUG 2022
Micro Frontends for Java Microservices - Cork JUG 2022Micro Frontends for Java Microservices - Cork JUG 2022
Micro Frontends for Java Microservices - Cork JUG 2022
 
Comparing Native Java REST API Frameworks - Seattle JUG 2022
Comparing Native Java REST API Frameworks - Seattle JUG 2022Comparing Native Java REST API Frameworks - Seattle JUG 2022
Comparing Native Java REST API Frameworks - Seattle JUG 2022
 
Reactive Java Microservices with Spring Boot and JHipster - Spring I/O 2022
Reactive Java Microservices with Spring Boot and JHipster - Spring I/O 2022Reactive Java Microservices with Spring Boot and JHipster - Spring I/O 2022
Reactive Java Microservices with Spring Boot and JHipster - Spring I/O 2022
 
Comparing Native Java REST API Frameworks - Devoxx France 2022
Comparing Native Java REST API Frameworks - Devoxx France 2022Comparing Native Java REST API Frameworks - Devoxx France 2022
Comparing Native Java REST API Frameworks - Devoxx France 2022
 
Lock That Sh*t Down! Auth Security Patterns for Apps, APIs, and Infra - Devne...
Lock That Sh*t Down! Auth Security Patterns for Apps, APIs, and Infra - Devne...Lock That Sh*t Down! Auth Security Patterns for Apps, APIs, and Infra - Devne...
Lock That Sh*t Down! Auth Security Patterns for Apps, APIs, and Infra - Devne...
 
Native Java with Spring Boot and JHipster - Garden State JUG 2021
Native Java with Spring Boot and JHipster - Garden State JUG 2021Native Java with Spring Boot and JHipster - Garden State JUG 2021
Native Java with Spring Boot and JHipster - Garden State JUG 2021
 
Java REST API Framework Comparison - PWX 2021
Java REST API Framework Comparison - PWX 2021Java REST API Framework Comparison - PWX 2021
Java REST API Framework Comparison - PWX 2021
 
Web App Security for Java Developers - PWX 2021
Web App Security for Java Developers - PWX 2021Web App Security for Java Developers - PWX 2021
Web App Security for Java Developers - PWX 2021
 
Mobile App Development with Ionic, React Native, and JHipster - Connect.Tech ...
Mobile App Development with Ionic, React Native, and JHipster - Connect.Tech ...Mobile App Development with Ionic, React Native, and JHipster - Connect.Tech ...
Mobile App Development with Ionic, React Native, and JHipster - Connect.Tech ...
 
Lock That Shit Down! Auth Security Patterns for Apps, APIs, and Infra - Joker...
Lock That Shit Down! Auth Security Patterns for Apps, APIs, and Infra - Joker...Lock That Shit Down! Auth Security Patterns for Apps, APIs, and Infra - Joker...
Lock That Shit Down! Auth Security Patterns for Apps, APIs, and Infra - Joker...
 
Web App Security for Java Developers - UberConf 2021
Web App Security for Java Developers - UberConf 2021Web App Security for Java Developers - UberConf 2021
Web App Security for Java Developers - UberConf 2021
 
Java REST API Framework Comparison - UberConf 2021
Java REST API Framework Comparison - UberConf 2021Java REST API Framework Comparison - UberConf 2021
Java REST API Framework Comparison - UberConf 2021
 
Native Java with Spring Boot and JHipster - SF JUG 2021
Native Java with Spring Boot and JHipster - SF JUG 2021Native Java with Spring Boot and JHipster - SF JUG 2021
Native Java with Spring Boot and JHipster - SF JUG 2021
 
Lock That Shit Down! Auth Security Patterns for Apps, APIs, and Infra - Sprin...
Lock That Shit Down! Auth Security Patterns for Apps, APIs, and Infra - Sprin...Lock That Shit Down! Auth Security Patterns for Apps, APIs, and Infra - Sprin...
Lock That Shit Down! Auth Security Patterns for Apps, APIs, and Infra - Sprin...
 
Reactive Java Microservices with Spring Boot and JHipster - Denver JUG 2021
Reactive Java Microservices with Spring Boot and JHipster - Denver JUG 2021Reactive Java Microservices with Spring Boot and JHipster - Denver JUG 2021
Reactive Java Microservices with Spring Boot and JHipster - Denver JUG 2021
 
Get Hip with JHipster - Colorado Springs Open Source User Group 2021
Get Hip with JHipster - Colorado Springs Open Source User Group 2021Get Hip with JHipster - Colorado Springs Open Source User Group 2021
Get Hip with JHipster - Colorado Springs Open Source User Group 2021
 
JHipster and Okta - JHipster Virtual Meetup December 2020
JHipster and Okta - JHipster Virtual Meetup December 2020JHipster and Okta - JHipster Virtual Meetup December 2020
JHipster and Okta - JHipster Virtual Meetup December 2020
 

Recently uploaded

State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 

Recently uploaded (20)

State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 

Migrating from Struts 1 to Struts 2

  • 1. Migrating from Struts 1 to Struts 2 Matt Raible, Virtuas Open Source Solutions mraible@virtuas.com © 2005-2006, Virtuas Open Source Solutions
  • 2. Introductions Your experience with Java? Your experience with Web Frameworks? What do you hope to learn today? Open Source experience: Ant, Struts, WebWork, Spring, Hibernate, Eclipse, Tomcat? Favorite IDE? Favorite OS? Favorite Server?
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19. Web Framework Experience Struts: used since June 2001 - same time 1.0 was released. Spring MVC: used since January 2004 - before 1.0 was released. WebWork: used since July 2004. Tapestry: used since July 2004. JSF: used since July 2004 - both Sun’s RI and MyFaces.
  • 20. Agenda 1. Struts Overview 2. WebWork Overview 3. Reasons for Upgrading 4. Migrating from Struts 1 to Struts 2 5. Migrating from WebWork 2 to Struts 2 6. Pitfalls 7. Q and A
  • 22. Struts 1.x Pros: The “Standard” - lots of Struts jobs Lots of information and examples HTML tag library is one of the best Cons: ActionForms - they’re a pain Can’t unit test - StrutsTestCase only does integration Project has been rumored as “dead”
  • 24. WebWork/Struts 2 Pros: Simple architecture - easy to extend Tag Library is easy to customize with FreeMarker or Velocity Interceptors are pretty slick Controller-based or page-based navigation Cons: Small Community Documentation is poorly organized
  • 27. WebWork Action public class UserAction extends ActionSupport { private UserManager mgr; private User user; private String id; public void setUserManager(UserManager userManager) { this.mgr = userManager; } public void setId(String id) { this.id = id; } public User getUser() { return user; } public String edit() { // check for an add if (id != null) { user = mgr.getUser(id); } else { user = new User(); } return SUCCESS; }
  • 28. WebWork Interceptors public class ValidationInterceptor extends AroundInterceptor { protected void after(ActionInvocation dispatcher, String result) throws Exception { } protected void before(ActionInvocation invocation) throws Exception { Action action = invocation.getAction(); String context = invocation.getProxy().getActionName(); final Map parameters = ActionContext.getContext().getParameters(); // don't validate on cancel, delete or GET if (ServletActionContext.getRequest().getMethod().equals(quot;GETquot;)) { log.debug(quot;Cancelling validation, detected GET requestquot;); } else if (parameters.containsKey(quot;cancelquot;) || parameters.containsKey(quot;deletequot;)) { log.debug(quot;Cancelling validation, detected clicking cancel or deletequot;); } else { ActionValidatorManager.validate(action, context); } } }
  • 29. xwork.xml <!-- List of Users --> <action name=quot;usersquot; class=quot;userActionquot; method=quot;listquot;> <result name=quot;successquot;>userList.jsp</result> <result name=quot;inputquot;>userList.jsp</result> </action> <!-- Edit User --> <action name=quot;editUserquot; class=quot;userActionquot; method=quot;editquot;> <result name=quot;successquot;>userForm.jsp</result> <result name=quot;inputquot;>userList.jsp</result> </action> <!-- Save User --> <action name=quot;saveUserquot; class=quot;userActionquot;> <result name=quot;cancelquot; type=quot;redirectquot;>users.html</result> <result name=quot;deletequot; type=quot;redirectquot;>users.html</result> <result name=quot;inputquot;>userForm.jsp</result> <result name=quot;successquot; type=quot;chainquot;>saveUserWithValidation</result> </action>
  • 30. WebWork JSP View <ww:form name=quot;userFormquot; action=quot;saveUserquot; method=quot;postquot; validate=quot;truequot;> <ww:hidden name=quot;user.idquot; value=quot;%{user.id}quot;/> <ww:textfield label=quot;%{getText('user.firstName')}quot; name=quot;user.firstNamequot; value=quot;%{user.firstName}quot; id=quot;user.firstNamequot;/> <ww:textfield label=quot;%{getText('user.lastName')}quot; name=quot;user.lastNamequot; value=quot;%{user.lastName}quot; required=quot;truequot;/> <ww:datepicker label=quot;%{getText('user.birthday')}quot; name=quot;user.birthdayquot; size=quot;11quot;/>
  • 31. WebWork DatePicker <ww:form name=quot;userFormquot; action=quot;saveUserquot; method=quot;postquot; validate=quot;truequot;> <ww:hidden name=quot;user.idquot; value=quot;%{user.id}quot;/> <ww:textfield label=quot;%{getText('user.firstName')}quot; name=quot;user.firstNamequot; value=quot;%{user.firstName}quot; id=quot;user.firstNamequot;/> <ww:textfield label=quot;%{getText('user.lastName')}quot; name=quot;user.lastNamequot; value=quot;%{user.lastName}quot; required=quot;truequot;/> <ww:datepicker label=quot;%{getText('user.birthday')}quot; name=quot;user.birthdayquot; size=quot;11quot;/>
  • 32. Page-based Navigation <%@ include file=quot;/common/taglibs.jspquot;%> <h2>Author Blogs</h2> <ww:action name=quot;authorsquot; id=quot;%{authors}quot; namespace=quot;defaultquot;/> <div class=quot;itemquot;> <ww:iterator value=quot;#authors.authorsquot; status=quot;indexquot;> <a href=quot;<ww:property value=quot;blog.feedUrlquot;/>quot;> <img src=quot;${ctxPath}/images/icons/xml.gifquot; alt=quot;XML Feedquot;/></a> <a href=quot;<ww:property value=quot;blog.urlquot;/>quot;><ww:property value=quot;namequot;/></a> <br /> </ww:iterator> </div>
  • 33. OGNL <ww:form name=quot;userFormquot; action=quot;saveUserquot; method=quot;postquot; validate=quot;truequot;> <ww:hidden name=quot;user.idquot; value=quot;%{user.id}quot;/> <ww:textfield label=quot;%{getText('user.firstName')}quot; name=quot;user.firstNamequot; value=quot;%{user.firstName}quot; id=quot;user.firstNamequot;/> <ww:textfield label=quot;%{getText('user.lastName')}quot; name=quot;user.lastNamequot; value=quot;%{user.lastName}quot; required=quot;truequot;/> </tr> <th><label for=quot;user.birthdayquot;><fmt:message key=quot;user.birthdayquot;/>:</label></th> <td> <ww:set name=quot;birthdayquot; scope=quot;requestquot; value=quot;(user.birthday instanceof java.util.Date) ? user.birthday : ''quot;/> <input type=quot;textquot; size=quot;11quot; name=quot;user.birthdayquot; id=quot;user.birthdayquot; value=quot;<fmt:formatDate value=quot;${birthday}quot; pattern=quot;${datePattern}quot;/>quot;/> [${datePattern}] </td> <tr>
  • 34. Struts 1 Struts 2
  • 35. Comparison Struts 1 Struts 2 Action Action ActionForm Action or POJO ActionForward Result struts-config.xml struts.xml ActionServlet FilterDispatcher RequestProcessor Interceptors validation.xml Action-validation.xml
  • 36. Features only in Struts 2 Page-based Navigation Built-in Ajax Support: DWR and Dojo Spring as default inversion of control container Changed from front-controller servlet to filter Much better client-side validation support QuickStart and Annotations JSF Support Built-in support for testing with StrutsTestCase
  • 38. Run Struts 1.x Actions <action name=quot;editGangsterquot; class=quot;org.apache.struts2.s1.Struts1Actionquot;> <param name=quot;classNamequot;> com.mycompany.gangstas.EditGangsterAction </param> <result> gangsterForm.jsp </result> </action>
  • 39. Equinox AppFuse Light - designed for quick apps with few requirements (i.e. prototypes) Includes 6 MVC implementations: JSF, Spring MVC, Struts 1, Struts 2, Tapestry and WebWork Includes 5 Persistence frameworks: Hibernate, iBATIS, JDO, OJB, Spring JDBC 50 combinations available! Located at http://equinox.dev.java.net
  • 41. WebWork 2 Struts 2
  • 42. Comparison WebWork 2 Struts 2 com.opensymphony.xwork.* com.opensymphony.xwork2.* com.opensymphony.webwork.* org.apache.struts2.* xwork.xml struts.xml webwork.properties struts.properties <ww:*/> <s:*/>
  • 45. Learn more from... Don Brown's Struts 2.0 presentation/article: http://us.apachecon.com/presentations/WE9/WE9- struts-2.0.ppt http://www.oreillynet.com/onjava/blog/2006/10/ my_history_of_struts_2.html InfoQ's Migrating to Struts 2 articles: http://infoq.com/articles/converting-struts-2-part1 http://infoq.com/news/struts2-migration-part2
  • 46. Questions? Struts Project: http://struts.apache.org Community: http://struts.apache.org/mail.html Tutorials: http://cwiki.apache.org/confluence/display/ WW/Tutorials Kickstart your development with Equinox: https://equinox.dev.java.net