Jakarta Struts Live by Richard Hightower

Total Page:16

File Type:pdf, Size:1020Kb

Jakarta Struts Live by Richard Hightower Jakarta Struts Live by Richard Hightower Copyright © 2004 by SourceBeat, LLC. Cover Copyright © 2004 by SourceBeat, LLC. All rights reserved. Published by SourceBeat, LLC, Highlands Ranch, Colorado. Managing Editor: James Goodwill Technical Editor: Kelly Clauson Copy Editor: Brent Barkley Layout Designer: Amy Kesic Cover Designer: Max Hays ISBN: 0974884308 Many designations used by organizations to distinguish their products are claimed as trademarks. These trademarked names may appear in this book. We use the names in an editorial fashion only with no intention of infringing on the trademark; therefore you will not see the use of a trademark symbol with every occurrence of the trademarked name. As every precaution has been taken in writing this book, the author and publisher will in no way be held liable for any loss or damages resulting from the use of information contained in this book. Table of Contents Dedication . viii Acknowledgments . ix About the Author . x Preface . xi Introduction . xii Chapter 1: Struts Quick Start Tutorial . 1 Download Struts . 3 Set up a J2EE Web Application Project That Uses Struts . 4 Write Your First Action . 5 Write Your First “Forward” . 6 Configure the Action and Forward in the Struts Configuration File . 7 Run and Test Your First Struts Application . 9 Debug Struts-Config.xml with the Struts Console . 11 Add Logging Support with Log4J and Commons Logging . 13 Write Your First ActionForm . 17 Write Your First Input View (JSP Page) . 20 Update the Action to Handle the Form and Cancel Buttons . 27 Set up the Database Pooling with Struts . 28 Exception Handling with Struts . 32 Display an Object with Struts Tags . 35 Using Logic Tags to Iterate over Users . 37 Summary . 42 Chapter 2: Testing Struts . 43 Testing Model Code with JUnit . 44 Getting Started with JUnit . 45 Using JUnit Step-by-Step . 45 Applying JUnit to Our Struts Tutorial . 51 Testing Struts Actions with StrutsTestCase . 58 Using StrutsTestCase (Mock Mode) Step-by-Step . 59 Using StrutsTestCase (Cactus Mode) . 69 Testing JSP with jWebUnit . 70 Using jWebUnit Step-by-Step . 70 Summary . 73 Chapter 3: Working with ActionForms and DynaActionForms . 74 Defining an ActionForm . 75 Understanding the Life Cycle of an ActionForm . 75 The Do’s and Don’ts of Automatic Type Conversion . 78 Jakarta Struts Live Table of Contents iv What an ActionForm Is . 79 Data Supplier: Supplies Data to html:form . 79 Data Collector: Processes Data from html:form . 79 Action Firewall: Validates Data before the Action Sees It . 79 What an ActionForm is Not . 80 Not Part of the Model or Data Transfer Object . 80 Not an Action, Nor Should It Interact with the Model . 80 Reducing the Number of ActionForms . 81 Super ActionForms . 81 Mapped Back ActionForms . 82 DynaActionForms . 83 Session vs. Request Scope ActionForms . 84 Continue the Tutorial . 85 Make User Registration a Multi-Step Process: Part 1 . 85 Create the Address JavaBean Property: Part 2 (Nested Beans) . 103 Create the Phone JavaBean Indexed Property: Part 3 (Indexed Properties) . 105 Convert the User Registration to Use DynaActionForms: Part 4 (DynaActionForms) . 107 Create the Management Feature to Edit/Delete Listings . 109 Using Dynamic Properties: Part 5 . 119 Summary . 121 Chapter 4: The Validator Framework . 122 Getting Started with the Validator Framework . 123 Common Validator Rules . 130 Mask Rule . 131 Constants . 134 Working with Dates . 135 Working with E-Mail and Credit Cards . 136 Putting It All Together . ..
Recommended publications
  • Log4j-Users-Guide.Pdf
    ...................................................................................................................................... Apache Log4j 2 v. 2.2 User's Guide ...................................................................................................................................... The Apache Software Foundation 2015-02-22 T a b l e o f C o n t e n t s i Table of Contents ....................................................................................................................................... 1. Table of Contents . i 2. Introduction . 1 3. Architecture . 3 4. Log4j 1.x Migration . 10 5. API . 16 6. Configuration . 18 7. Web Applications and JSPs . 48 8. Plugins . 56 9. Lookups . 60 10. Appenders . 66 11. Layouts . 120 12. Filters . 140 13. Async Loggers . 153 14. JMX . 167 15. Logging Separation . 174 16. Extending Log4j . 176 17. Extending Log4j Configuration . 184 18. Custom Log Levels . 187 © 2 0 1 5 , T h e A p a c h e S o f t w a r e F o u n d a t i o n • A L L R I G H T S R E S E R V E D . T a b l e o f C o n t e n t s ii © 2 0 1 5 , T h e A p a c h e S o f t w a r e F o u n d a t i o n • A L L R I G H T S R E S E R V E D . 1 I n t r o d u c t i o n 1 1 Introduction ....................................................................................................................................... 1.1 Welcome to Log4j 2! 1.1.1 Introduction Almost every large application includes its own logging or tracing API. In conformance with this rule, the E.U.
    [Show full text]
  • Configuring & Using Apache Tomcat 4 a Tutorial on Installing and Using
    Configuring & Using Apache Tomcat 4 A Tutorial on Installing and Using Tomcat for Servlet and JSP Development Taken from Using-Tomcat-4 found on http://courses.coreservlets.com Following is a summary of installing and configuring Apache Tomcat 4 for use as a standalone Web server that supports servlets 2.3 and JSP 1.2. Integrating Tomcat as a plugin within the regular Apache server or a commercial Web server is more complicated (for details, see http://jakarta.apache.org/tomcat/tomcat-4.0-doc/). Integrating Tomcat with a regular Web server is valuable for a deployment scenario, but my goal here is to show how to use Tomcat as a development server on your desktop. Regardless of what deployment server you use, you'll want a standalone server on your desktop to use for development. (Note: Tomcat is sometimes referred to as Jakarta Tomcat since the Apache Java effort is known as "The Jakarta Project"). The examples here assume you are using Windows, but they can be easily adapted for Solaris, Linux, and other versions of Unix. I've gotten reports of successful use on MacOS X, but don't know the setup details. Except when I refer to specific Windows paths (e.g., C:\blah\blah), I use URL-style forward slashes for path separators (e.g., install_dir/webapps/ROOT). Adapt as necessary. The information here is adapted from More Servlets and JavaServer Pages from Sun Microsystems Press. For the book table of contents, index, source code, etc., please see http://www.moreservlets.com/. For information on servlet and JSP training courses (either at public venues or on-site at your company), please see http://courses.coreservlets.com.
    [Show full text]
  • Impassive Modernism in Arabic and Hebrew Literatures
    UNIVERSITY OF CALIFORNIA Los Angeles Against the Flow: Impassive Modernism in Arabic and Hebrew Literatures A dissertation submitted in partial satisfaction of the requirements for the degree Doctor of Philosophy in Comparative Literature by Shir Alon 2017 © Copyright by Shir Alon 2017 ABSTRACT OF THE DISSERTATION Against the Flow: Impassive Modernism in Arabic and Hebrew Literatures by Shir Alon Doctor of Philosophy in Comparative Literature University of California, Los Angeles, 2017 Professor Gil Hochberg, Co-Chair Professor Nouri Gana, Co-Chair Against the Flow: Impassive Modernism in Arabic and Hebrew Literatures elaborates two interventions in contemporary studies of Middle Eastern Literatures, Global Modernisms, and Comparative Literature: First, the dissertation elaborates a comparative framework to read twentieth century Arabic and Hebrew literatures side by side and in conversation, as two literary cultures sharing, beyond a contemporary reality of enmity and separation, a narrative of transition to modernity. The works analyzed in the dissertation, hailing from Lebanon, Palestine, Israel, Egypt, and Tunisia, emerge against the Hebrew and Arabic cultural and national renaissance movements, and the establishment of modern independent states in the Middle East. The dissertation stages encounters between Arabic and Hebrew literary works, exploring the ii parallel literary forms they develop in response to shared temporal narratives of a modernity outlined elsewhere and already, and in negotiation with Orientalist legacies. Secondly, the dissertation develops a generic-formal framework to address the proliferation of static and decadent texts emerging in a cultural landscape of national revival and its aftermaths, which I name impassive modernism. Viewed against modernism’s emphatic features, impassive modernism is characterized by affective and formal investment in stasis, immobility, or immutability: suspension in space or time and a desire for nonproductivity.
    [Show full text]
  • Osgi and GWT Integration Via Pax-Web and Maven (V:0.01)
    OSGi and GWT integration via Pax-web and Maven (v:0.01) Sergio Blanco Diez Ignacio Diaz de Sarralde Carvajal January 13, 2010 Contents 1 Introduction 2 2 GWT 3 2.1 Toolkit overview.....................................3 2.1.1 Development overview..............................3 2.1.2 Google Web Toolkit component overview...................4 2.2 Workflow.........................................4 2.2.1 Project creation.................................4 2.2.2 Project structure.................................5 2.2.3 \Hosted" or Development server........................6 2.2.4 Module definition; .gwt.xml files........................8 2.2.5 Coding the client; GWT Widgets........................9 2.2.6 Coding the server; Remote Procedure Calls.................. 12 2.3 Other features...................................... 14 2.3.1 Internationalization............................... 14 2.3.2 Declarative User Interfaces........................... 14 3 OSGi and GWT integration 17 3.1 Creating the GWT Project............................... 17 3.2 Things to consider in GWT Maven projects...................... 20 3.3 Enabling OSGi in the GWT project.......................... 20 3.3.1 Turning the GWT project into a bundle.................... 20 3.3.2 Dependencies management........................... 25 3.3.3 Run using Pax Runner.............................. 28 1 Chapter 1 Introduction When developing complex OSGi applications it is usual to implement one or more web frontends, be them for end users or for consumption by other systems. OSGi provides a standard way to register servlets and resources under different URLs, but creating complex frontends can be dif- ficult and time consuming. When the frontend is SOA based, solutions like Apache CXF help exposing internal services via web services or REST. But if the frontend must be a fairly complex web application in itself, complexity rises.
    [Show full text]
  • In Re Equifax Inc. Securities Litigation 17-CV-03463-Consolidated Class
    Case 1:17-cv-03463-TWT Document 49 Filed 04/23/18 Page 1 of 198 UNITED STATES DISTRICT COURT NORTHERN DISTRICT OF GEORGIA ATLANTA DIVISION IN RE EQUIFAX INC. SECURITIES Consolidated Case No. LITIGATION 1:17-cv-03463-TWT CONSOLIDATED CLASS ACTION COMPLAINT FOR VIOLATIONS OF THE FEDERAL SECURITIES LAWS Case 1:17-cv-03463-TWT Document 49 Filed 04/23/18 Page 2 of 198 TABLE OF CONTENTS Page I. PRELIMINARY STATEMENT .....................................................................2 II. PARTIES .......................................................................................................10 A. Lead Plaintiff ...................................................................................... 10 B. Defendants .......................................................................................... 10 1. Equifax, Inc. ............................................................................. 10 2. Individual Defendants .............................................................. 12 III. JURISDICTION AND VENUE ....................................................................13 IV. SUMMARY OF THE FRAUD .....................................................................13 A. Equifax’s Business is to Collect and Sell Sensitive Personal Information About Global Consumers ............................................... 13 B. Defendants Knew that Securing the Information Equifax Collected Was Critical to the Company’s Business ........................... 16 C. Defendants Issue Statements Touting Cybersecurity, Compliance with
    [Show full text]
  • Web Development with Java
    Web Development with Java Tim Downey Web Development with Java Using Hibernate, JSPs and Servlets Tim Downey, BS, MS Florida International University Miami, FL 33199, USA British Library Cataloguing in Publication Data A catalogue record for this book is available from the British Library Library of Congress Control Number: 2007925710 ISBN: 978-1-84628-862-3 e-ISBN: 978-1-84628-863-0 Printed on acid-free paper © Springer-Verlag London Limited 2007 Apart from any fair dealing for the purposes of research or private study, or criticism or review, as permitted under the Copyright, Designs and Patents Act 1988, this publication may only be reproduced, stored or transmitted, in any form or by any means, with the prior permission in writing of the pub- lishers, or in the case of reprographic reproduction in accordance with the terms of licences issued by the Copyright Licensing Agency. Enquiries concerning reproduction outside those terms should be sent to the publishers. The use of registered names, trademarks, etc. in this publication does not imply, even in the absence of a specifi c statement, that such names are exempt from the relevant laws and regulations and therefore free for general use. The publisher makes no representation, express or implied, with regard to the accuracy of the informa- tion contained in this book and cannot accept any legal responsibility or liability for any errors or omissions that may be made. 9 8 7 6 5 4 3 2 1 Springer Science+Business Media springer.com To Bobbi, my sweetheart, with all my love. Preface I have been teaching web development for ten years.
    [Show full text]
  • Enterprise Development with Flex
    Enterprise Development with Flex Enterprise Development with Flex Yakov Fain, Victor Rasputnis, and Anatole Tartakovsky Beijing • Cambridge • Farnham • Köln • Sebastopol • Taipei • Tokyo Enterprise Development with Flex by Yakov Fain, Victor Rasputnis, and Anatole Tartakovsky Copyright © 2010 Yakov Fain, Victor Rasputnis, and Anatole Tartakovsky.. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://my.safaribooksonline.com). For more information, contact our corporate/institutional sales department: (800) 998-9938 or [email protected]. Editor: Mary E. Treseler Indexer: Ellen Troutman Development Editor: Linda Laflamme Cover Designer: Karen Montgomery Production Editor: Adam Zaremba Interior Designer: David Futato Copyeditor: Nancy Kotary Illustrator: Robert Romano Proofreader: Sada Preisch Printing History: March 2010: First Edition. Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. Enterprise Development with Flex, the image of red-crested wood-quails, and related trade dress are trademarks of O’Reilly Media, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information con- tained herein.
    [Show full text]
  • Developing Webapps Faster with Appfuse Matt Raible [email protected]
    Developing webapps faster with AppFuse Matt Raible [email protected] !ww.raibledesigns.co" Who is Matt Raible? • Developing websites since 1994 (before Netscape 1.0) - Developing in Java since 1999 • Committer on several open source projects: Roller Weblogger, Struts Menu, Display Tag, AppFuse, Struts Resume • Have a weblog (http://raibledesigns.com) with tips n’ tricks for J2EE and web development • Author: Spring Live (SourceBeat) and contributor to Pro JSP (Apress) !ww.raibledesigns.co" Audience Questions • Your Experience with webapps? • What do you want to get from this presentation? • Open Source experience with Ant, XDoclet, Struts, Hibernate, Spring? !ww.raibledesigns.co" Presentation Agenda • What is AppFuse? • Open Source Dependencies • Demo of Features • HowTo: Create Person object and DAO to persist • Questions? !ww.raibledesigns.co" AppFuse - what is it? • History - how it came to be • Powered by Ant, glued together with Spring, persisted by Hibernate and controlled with Struts • Easy setup (ant setup) for Tomcat and MySQL • Testing on all tiers: DAOs, Business Delegates, Struts Actions and JSPs !ww.raibledesigns.co" Dependencies !ww.raibledesigns.co" Demo of Features • Container Managed Authentication - easily switch from JDBC to LDAP or Windows domain authentication • Remember Me and Self Registration • GZip Compression Built-in • Testing environment ready to go, Anthill ready • http://demo.raibledesigns.com/appfuse !ww.raibledesigns.co" Create database, table, POJO and DAO A Quick HowTo !ww.raibledesigns.co" Development
    [Show full text]
  • Kony Mobilefabric Integration Service - Manual Upgrade Version 1.3
    Kony MobileFabricTM Integration Service - Manual Upgrade Release 7.2 Document Relevance and Accuracy This document is considered relevant to the Release stated on this title page and the document version stated on the Revision History page. Remember to always view and download the latest document version relevant to the software release you are using. © 2016 by Kony, Inc. All rights reserved 1 of 130 Kony MobileFabric Integration Service - Manual Upgrade Version 1.3 Copyright © 2013 by Kony, Inc. All rights reserved. October, 2016 This document contains information proprietary to Kony, Inc., is bound by the Kony license agreements and may not be used except in the context of understanding the use and methods of Kony Inc, software without prior, express, written permission. Kony, Empowering Everywhere, Kony MobileFabric, Kony Nitro, and Kony Visualizer are trademarks of Kony, Inc. Microsoft, the Microsoft logo, Internet Explorer, Windows, and Windows Vista are registered trademarks of Microsoft Corporation. Apple, the Apple logo, iTunes, iPhone, iPad, OS X, Objective-C, Safari, Apple Pay, Apple Watch and Xcode are trademarks or registered trademarks of Apple, Inc. Google, the Google logo, Android, and the Android logo are registered trademarks of Google, Inc. Chrome is a trademark of Google, Inc. BlackBerry, PlayBook, Research in Motion, and RIM are registered trademarks of BlackBerry. All other terms, trademarks, or service marks mentioned in this document have been capitalized and are to be considered the property of their respective owners. © 2016 by Kony, Inc. All rights reserved 2 of 130 Kony MobileFabric Integration Service - Manual Upgrade Version 1.3 Revision History Date Document Description of Modifications/Release Version 10/24/2016 1.3 Document updated for release 7.2 07/20/2016 1.2 Document updated for release 7.1 06/10/2016 1.1 Appended new section Upgrading Tomcat from 5.0.x to 7.0.x.
    [Show full text]
  • Migrating from Struts 1 to Struts 2
    Migrating from Struts 1 to Struts 2 Matt Raible, Virtuas Open Source Solutions [email protected] © 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
    [Show full text]
  • Oracle Fusion Middleware Configuring Log Files and Filtering Log Messages for Oracle Weblogic Server, 11G Release 1 (10.3.6) E13739-07
    Oracle® Fusion Middleware Configuring Log Files and Filtering Log Messages for Oracle WebLogic Server 11g Release 1 (10.3.6) E13739-07 September 2013 This document describes how you use WebLogic Server logging services to monitor server, subsystem, and application events. Oracle Fusion Middleware Configuring Log Files and Filtering Log Messages for Oracle WebLogic Server, 11g Release 1 (10.3.6) E13739-07 Copyright © 2007, 2013, Oracle and/or its affiliates. All rights reserved. This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited. The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing. If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, the following notice is applicable: U.S. GOVERNMENT RIGHTS Programs, software, databases, and related documentation and technical data delivered to U.S. Government customers are "commercial computer software" or "commercial technical data" pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, the use, duplication, disclosure, modification, and adaptation shall be subject to the restrictions and license terms set forth in the applicable Government contract, and, to the extent applicable by the terms of the Government contract, the additional rights set forth in FAR 52.227-19, Commercial Computer Software License (December 2007).
    [Show full text]
  • Version Control: a Case Study in the Challenges and Opportunities For
    Version Control: A Case Study in the Challenges and Opportunities for Open Source Software Development (Position Paper for 2nd Workshop on Open Source Software Engineering) Mark C. Chu-Carroll, David Shields and Jim Wright {mcc,shields,jwright}@watson.ibm.com IBM T. J. Watson Research Center 19 Skyline Drive, Hawthorne, NY 10522 Abstract variants of the kernel source tree [2] , and problems coordinating updates and the addition of The growth of the worldwide open source new features have been reported, as noted in a development effort, driven in part by the recent discussion of Virtual Memory Managers [3] . entrance of large corporations into the open source Torvalds has recognized these problems [4] , and arena, offers new opportunities to improve the recently reported that he is using the Bitkeeper software engineering tools available for that effort. version control system [5, 6, 7] . Indeed, the increasing difficulty of managing large Compiling the Linux kernel itself presents a open source projects, as well as that of integrating complicated configuration problem, recently related efforts into new programming addressed by Eric Raymond, the author of CML2 environments, represents a challenge that must be [8]," a configuration system ... that handles build- met if the rapid growth of open source software is option selection for Linux kernels" that is to continue. This position paper addresses these "scheduled to be integrated into the Linux kernel issues in the context of software version control. source tree between 2.5.1 and 2.5.2." (Text in quotes, here and later on, is from the referenced Version Control and the Linux Kernel web sites.) CML2 is written in Python and, according to the CML2 Announcement [9]: "For The Linux kernel, perhaps the most crucial piece of those of you who grumbled about adding Python to open source software, represents an interesting the build-tools set, Linux has uttered a ukase: example in that the kernel developers use a CML2's reliance on Python is not an issue" (See primitive form of version control.
    [Show full text]