Apache Struts 2 Web Application Development
Design, develop, test, and deploy your web applications using the Struts 2 framework
Dave Newton
BIRMINGHAM - MUMBAI
This material is copyright and is licensed for the sole use by Paul Corcorran on 5th July 2009 8601 ave. p #1, , lubbock, , 79423
Apache Struts 2 Web Application Development Copyright © 2009 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, Packt Publishing, nor its dealers or distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: June 2009
Production Reference: 2040609
Published by Packt Publishing Ltd. 32 Lincoln Road Olton Birmingham, B27 6PA, UK. ISBN 978-1-847193-39-1 www.packtpub.com
Cover Image by Vinayak Chittar (
[email protected])
This material is copyright and is licensed for the sole use by Paul Corcorran on 5th July 2009 8601 ave. p #1, , lubbock, , 79423
Credits Author Dave Newton Reviewers Sandeep Jadav
Indexer Monica Ajmera Editorial Team Leader Akshara Aware
Dale Newfield Michael Minella Sharad Sharma Acquisition Editor Viraj Joshi Development Editor Ved Prakash Jha Technical Editor Gaurav Datar
Project Team Leader Lata Basantani Project Coordinator Abhijeet Deobhakta Proofreader Joel T. Johnson Production Coordinators Shantanu Zagade Adline Swetha Jesuthas
Copy Editors Sumathi Sridhar Leonard D'Silva
Cover Work Shantanu Zagade
This material is copyright and is licensed for the sole use by Paul Corcorran on 5th July 2009 8601 ave. p #1, , lubbock, , 79423
About the author Dave has been programming for as long as he can remember, and probably a bit
longer than that. He began by playing a Star Trek game on a library computer, and quickly graduated to educating his grade school teachers about computers and the BASIC language. Receiving a TRS-80 Model 1 was pretty much the end of his social life, and he's never looked back. A diverse background in both programming languages and problem spaces has provided him with a wide range of experience. Using a diverse set of languages, which includes Pascal, Forth, Fortran, Lisp, Smalltalk, assembly, C/C++, Java, and Ruby, brings an appreciation for many programming paradigms. Working on AI, embedded systems, device drivers, and both desktop and web application programming, has brought him an appreciation for the problems and solutions that each environment offers. Even after thirty years of typing in his first infinite loop, he's still entertained by the process of programming. He never tires of looking for ways to do less work, and is convinced that he should never have to repeat himself to a computer. He still occasionally writes an infinite loop.
This material is copyright and is licensed for the sole use by Paul Corcorran on 5th July 2009 8601 ave. p #1, , lubbock, , 79423
Acknowledgement I'd like to thank Packt for providing me an opportunity to share what I hope is some useful information about my favorite Java web application framework, Struts 2, and along the way, throw in some techniques I've found my clients appreciate (and many of them mean I get to do less work, so it's a win-win!) My parents, of course, deserve far more thanks than I could ever hope to express. From them, I received a robust sense of exploration and curiosity, which are traits that have served me well during my personal and professional career. They, and the rest of my family, have prodded me along by continually asking, "How's the book coming?", which was surprisingly motivating. They have also provided, along with my friends, much needed moral support during recent months. I'd like to thank my co-workers, who have zero compunction about telling me when I'm completely wrong, and who provide me with a constant stream of ideas about programming, the associated processes, and how to make programming easier and more flexible. The creators of the frameworks and libraries we use every day deserve more than they usually receive. Putting one's code out there for everyone to see and use is a brave step. They're under-appreciated when everything works, and unfairly punished when it doesn't. I hope this book pays homage to them in some small way, and contributes back to the various communities that have made my programming work easier. Finally, the open source and Java communities deserve a hearty "Huzzah!" It includes places like the Struts 2 mailing lists, where all types of developers contribute by asking and answering questions, making suggestions, and politely reminding those involved with the framework that our documentation could be better. It also includes JavaRanch, where "No question is too simple", and sometimes the "simplest" questions turn out to be surprisingly interesting. Finally, the Apache Foundation and fellow Struts developers, who have made Struts possible in all its incarnations. All those people who write the code that we use, contribute to discussions, and try to help others out know who they are. I can't possibly begin to list all of them, but thanks.
This material is copyright and is licensed for the sole use by Paul Corcorran on 5th July 2009 8601 ave. p #1, , lubbock, , 79423
About the reviewers Sandeep Jadav has been in the IT industry for three years and is currently working
as a Software Engineer for an IT firm. Sandeep is an MCA qualified professional and is well-versed with Java technologies. He empowers people around him to work and play better, by helping them resolve complex issues with the simplest and most durable solutions. In addition to reviewing, Sandeep has a history of using his technical skills for more practical purposes—providing technical leadership to past companies. He has an experience in developing on a large scale, n-tier and Web applications, for business and engineering uses.
Sandeep has a large network of friends and makes frequent contributions to a variety of content areas in many online IT communities. I would first like to thank Packt Publishing, and the author Dave Newton, for spearheading this edition of Apache Struts 2 Web Application Development, and giving me an opportunity to revisit and improve upon the first efforts. I am deeply grateful to my family for allowing me to encroach on many months of what should have been my family's quality time. I extend my deepest appreciation to my friends, for all their support, encouragement, and guidance throughout my work. I appreciate Packt Publishing for allowing me to gain a very new and delighting experience of reviewing the book. While reviewing may seem a solitary pursuit, it is actually very much a collaborative effort, and as such, I extend my thanks and appreciation to my author, editor, and the staff at Packt Publishing for their support throughout this project. Finally, I especially thank Payal for providing great support on each and every step of my life.
This material is copyright and is licensed for the sole use by Paul Corcorran on 5th July 2009 8601 ave. p #1, , lubbock, , 79423
Dale Newfield is a computer scientist trained at Carnegie Mellon and the University of Virginia (ABD). Mr. Newfield has designed, built, and maintained a wide variety of systems in many languages. He has vertical knowledge in fields as disparate as graphics, user interfaces, virtual environments, networking, network technology design, network modeling, distributed and disconnected computation, bioinformatics, along with both web and POS systems requiring tight integration of hardware and software. Having built scalable web applications using both Struts1 and Struts2, his input was helpful in keeping this text focused on teaching best practices. Michael T Minella has been working with, and teaching about, open source
software and agile methodologies for over seven years. He holds degrees from Northern Illinois University and DePaul University in Computer Science and E-Commerce Technologies respectively.
Michael lives just outside Chicago, IL, and works at a major financial exchange there. In addition to his day job, Michael currently teaches at DeVry University, has authored a Refcard on JUnit and EasyMock (http://refcardz.dzone. com/refcardz/junit-and-easymock), and maintains the site http://www. michaelminella.com. Michael would like to thank his wife Erica for her continued support in all the ways he expands his career.
Sharad Sharma is working as a Software Engineer with a reputed MNC. He completed his Bachelors in Technology (B.Tech) from Sikkim Manipal University, Sikkim, and has a passion to learn and teach new technologies. He has successfully completed many projects based on Java/J2EE technology. In spite of having less experience, due to his dedication and hard work, he was able to achieve the top position among all the developers of the organization. This is the first book he has worked upon and wishes to work on many more in future. I would like to thank my family and friends for the support they have provided me in all the areas.
This material is copyright and is licensed for the sole use by Paul Corcorran on 5th July 2009 8601 ave. p #1, , lubbock, , 79423
This material is copyright and is licensed for the sole use by Paul Corcorran on 5th July 2009 8601 ave. p #1, , lubbock, , 79423
Table of Contents Preface Chapter 1: Struts and Agile Development
1 7
Struts 2 in a nutshell The filter dispatcher Interceptors Actions Results Plug-ins Agile in a nutshell User stories Testing Refactoring Short iterations Real applications in a nutshell Making it pretty JavaScript Documentation All of the rest Getting started Creating our own applications
7 8 8 9 9 10 10 11 11 11 11 12 12 13 13 13 13 14
Summary
15
Doing it "by hand" Using Maven
Chapter 2: Basic Configuration Setting up our environment A sanity-checking application Configuring web.xml for Struts 2 Writing our first action
14 14
17
17 18 19 20
This material is copyright and is licensed for the sole use by Paul Corcorran on 5th July 2009 8601 ave. p #1, , lubbock, , 79423
Table of Contents Configuring our first action with XML Configuring our result Choosing an action method
20 21 22
Getting started with our application Gathering user stories—defining our application Building skeletal applications using wildcards Matching multiple wildcards More wildcard tricks Packages and namespaces Creating site navigation Including external configuration files Our application so far Examining our configuration Configuration via convention and annotations
23 23 24 25 25 26 26 28 28 29 30
Summary
34
The Convention Plug-in and action-less actions The Convention Plug-in and action configuration Configuring the Convention Plug-in with annotations
Chapter 3: Actions and ActionSupport ActionSupport and its interfaces The Action interface Action's convenience strings
30 31 32
35
35 36
36
The TextProvider interface Detour—action properties, JSPs, and more tags Continuing with message lookup Parameterized messages The LocaleProvider interface The Validateable and ValidationAware interfaces Implementing our first user story Refining our story Creating the recipe form Adding some validation Displaying our error messages More action interfaces Detour—creating the list of interfaces to explore
36 38 41 42 44 44 45 45 46 48 49 49 50
Additional action interfaces Preparable interface Accessing scoped attributes (and request parameters)
53 53 53
Leveraging the IDE Using the command line Examining class files
50 51 52
[ ii ]
This material is copyright and is licensed for the sole use by Paul Corcorran on 5th July 2009 8601 ave. p #1, , lubbock, , 79423
Table of Contents
Accessing servlet objects Request parameter/action property filtering Summary
54 55 55
Chapter 4: Results and Result Types
57
Chapter 5: OGNL, the Value Stack, and Custom Tags
83
The dispatcher result type The redirect result type The redirectAction result type The chain result type (action chaining) The parse parameter and a usecase detour Displaying the form Coding our action Configuring our success result Type conversion sneak attack Coding the show action The FreeMarker and Velocity result types FreeMarker result configuration The XSLT result type The plaintext result The stream result The httpheader result The Tiles and JasperReports results Creating custom result types Configuring our custom result type Writing the action Implementing our markdown result type Summary
OGNL Contents of the value stack and the tag Escaping values Default values Escaping values for JavaScript
Other value stack objects and the debug tag A dirty EL trick The tag Calling static methods from OGNL Conditionals Collections and iteration The tag
57 59 59 61 61 62 63 64 66 66 69 70 71 73 73 74 74 74 76 76 77 80 83 84
84 85 85
85 87 88 88 89 89 90
[ iii ]
This material is copyright and is licensed for the sole use by Paul Corcorran on 5th July 2009 8601 ave. p #1, , lubbock, , 79423
Table of Contents Tracking iteration status CSS detour: Alternating table row background color The tag It's not a list, it's an iterator! Silent death Another potential stumper (Struts 2.0 only) What is for?
The tag The tag The tag
Arbitrary filtering with the tag Dirty OGNL secrets
The tag Are the collection tags useful? Referencing other pages and actions The tag The tag The tag Summary
Chapter 6: Form Tags
Form tag basics The xhtml theme in a nutshell The tag The tag Common input element tag attributes Values, labels, and names (and keys) All the rest
91 92 94 95 95 95 96
97 98 98
100 101
102 102 103 103 103 105 108
109
109 110 110 111 112
112 113
Basic rendering
113
Basic form input elements
114
Combination form tags
122
But I don't want tables
114
The , , and tags The tag The tag The tag The tag The tag Using the tag to implement a user story The tag The tag The tag The tag The tag The tag
114 114 115 115 117 118 118 120 121 121 122 122 123
[ iv ]
This material is copyright and is licensed for the sole use by Paul Corcorran on 5th July 2009 8601 ave. p #1, , lubbock, , 79423
Table of Contents The tag The tag
Uploading files Preventing double submits with the tag Summary
Chapter 7: Form Validation and Type Conversion Form validation Manual validation Configuring XML validation
Customizing validation messages
124 125
126 128 129
131
131 132 132
134
What validations are available?
135
Configuring validation with annotations
146
The requiredstring validator The stringlength validator Detour—playing games with validation messages The required and int validators But wait, there's more The double validator The email validator The url validator The date validator The regex validator The expression and fieldexpression validators Combining validation methods The conversion validator The visitor validator The @Validation annotation The @Validations annotation The @SkipValidation annotation The @RequiredFieldValidator annotation The @IntRangeFieldValidator annotation The @DoubleRangeFieldValidator annotation The remaining validation annotations
Client-side validation Custom validators Type conversion The problem The solution Defining our own converters
Type conversion usecase—trimmed BigDecimals Configuring conversion across the entire application Custom type conversion is handy
Collections
Usecase—adding a list of ingredients
136 136 137 140 141 142 142 142 142 143 143 145 146 146 146 147 148 148 149 149 149
150 151 153 154 154 155
155 157 157
158
158
[]
This material is copyright and is licensed for the sole use by Paul Corcorran on 5th July 2009 8601 ave. p #1, , lubbock, , 79423
Table of Contents Updating our new recipe form Map-based collections
159 164
Summary
164
Chapter 8: Interceptors
The basics Configuring interceptor stacks Configuring interceptors Configuring interceptors for individual actions How interceptors work Interceptors in the default stack The exception interceptor The alias interceptor The servletConfig interceptor The prepare interceptor The i18n interceptor The chain interceptor The debugging interceptor The profiling interceptor The scopedModelDriven interceptor The modelDriven interceptor Getting back to the scopedModelDriven interceptor
The fileUpload interceptor The checkbox interceptor The staticParams interceptor The params interceptor
Ordered parameters and ad hoc factory patterns
The conversionError interceptor The validation interceptor The workflow interceptor Other important interceptors and interceptor stacks The token interceptor The store interceptor The roles Interceptor The clearSession interceptor The paramsPrepareParamsStack interceptor stack Writing our own interceptors The trim interceptor Configuring the trim interceptor The Test Action Testing the trim interceptor
167
167 168 169 171 172 173 173 173 173 174 175 175 176 176 177 177
178
178 179 179 180
180
181 181 182 182 182 182 183 183 183 184 184 186 188 188
[ vi ]
This material is copyright and is licensed for the sole use by Paul Corcorran on 5th July 2009 8601 ave. p #1, , lubbock, , 79423
Table of Contents
Modifying application flow with interceptors
Configuring the result Writing the ResultMappingInterceptor Writing the ResultMappingInterceptor and making it work
Summary
189
189 190 191
192
Chapter 9: Exceptions and Logging
193
Checked versus unchecked exceptions Application-specific exceptions Abstracting underlying exceptions
196 196 199
Handling exceptions in Struts 2 Global exception mappings Action-specific exception mappings Accessing the exception Architecting exceptions and exception handling
193 194 194 195 195
Handling exceptions Logging Introduction to logging
200 200 201
Summary
205
Using the loggers Configuring the loggers
201 203
Chapter 10: Getting Started with JavaScript Introduction to JavaScript Playing with JavaScript Minor syntax and language notes Unicode Whitespace Semicolons Null and undefined values The equal and strict equal operators The logical OR operator Variables and scoping JavaScript data types Numbers Strings Arrays
Exception handling Introduction to JavaScript objects and OOP Open objects and object augmentation Object values can be functions Object maker functions
207
208 208 208 208 208 209 209 209 209 210 212
212 213 214
215 216 217 218 218
[ vii ]
This material is copyright and is licensed for the sole use by Paul Corcorran on 5th July 2009 8601 ave. p #1, , lubbock, , 79423
Table of Contents
Functions Function parameters
218 219
Inner functions Closures Introduction to JavaScript classes Creating classes
221 222 223 223
Prototypes JavaScript modules and OOP Creating a namespace Summary
227 227 228 228
Some trickery
Variable and function access JavaScript's "this" keyword
Chapter 11: Advanced JavaScript, the DOM, and CSS The importance of markup ID or style attribute? Dressing up our form
JavaScript modules and jQuery
220
224 226
231
232 232 232
235
Adding onclick handlers
236
Using a function builder Accessing module data The final trick
Adding dynamic form elements Identifying where to add the elements The JavaScript "Recipe" module Summary
237 239 241
242 242 243 247
Chapter 12: Themes and Templates
249
Chapter 13: Rich Internet Applications
257
Extracting the templates A maze of twisty little passages Creating our theme Other uses of templates Summary
What this chapter is and isn't Dojo tags Simple use cases really are simple The Dojo tag The Dojo tag A brief side journey on topics
249 250 251 254 255 257 258 258 258 259 261
[ viii ]
This material is copyright and is licensed for the sole use by Paul Corcorran on 5th July 2009 8601 ave. p #1, , lubbock, , 79423
Table of Contents
The Dojo tag
263
Finishing our user story Highlighting the need to know
263 263
Dojo and forms The REST plug-in REST in a nutshell The REST plug-in in a nutshell
265 266 266 266
A web browser client example
268
An example of a useful client A command-line example Custom content handler example
271 273 275
REST plug-in URLs REST plug-in results
266 267
The REST controller REST controller responses
268 269
YAML in a nutshell Writing our YAML handler Configuring our YAML handler Handling our YAML
275 276 276 277
Summary
278
Chapter 14: Comprehensive Testing
281
Revisiting our iterator filter The test environment The initial test stub Testing vowel recognition Testing non-string parameter exceptions Test granularity and test setup
283 284 284 285 286 287
Test-driven development Unit testing Test, code, refactor—the "heartbeat" of TDD JUnit
281 282 283 283
TestNG Legacy code and unit testing Simple action testing
288 290 291
Detour: Struts and Spring in a nutshell
294
Detour: Dependency Injection (Inversion of Control) Dependency Injection helps us test Spring web.xml configuration Spring context configuration file
Testing Struts 2 in context Testing a Struts interceptor Client-side (functional) testing Selenium
291 293 295 295
296 297 299 300 [ ix ]
This material is copyright and is licensed for the sole use by Paul Corcorran on 5th July 2009 8601 ave. p #1, , lubbock, , 79423
Table of Contents Selenium RC The test scenario Our first Selenium test
300 300 300
Other forms of testing Acceptance testing Load testing
304 304 305
Recovery testing Summary
307 308
Load testing with JMeter
305
Chapter 15: Documenting our Application Documenting Java Self-documenting code
Document why, not what Make your code read like the problem Contract-oriented programming
309
309 310
310 311 313
Javadocs
317
Using UML
324
Always write Javadocs! The first sentence Add information beyond the API name Write for multiple formats Generating targeted Javadocs The -use argument Creating new Javadoc tags with the -tag argument Never write Javadocs! Never write inline Java comments! Package diagrams Class diagrams Sequence diagrams
317 318 319 320 321 321 322 323 323 324 324 325
Documenting web applications High-level overviews Documenting JSPs Documenting JavaScript Documenting interaction
327 328 328 329 333
User documentation Documenting development Source code control systems
335 335 336
More UML and the power of scribbling Don't spend so much time making pretty pictures
Code and mental history Commit comment commitment When (and what) do we commit
334 334
336 336 337
[]
This material is copyright and is licensed for the sole use by Paul Corcorran on 5th July 2009 8601 ave. p #1, , lubbock, , 79423
Table of Contents Branching Branching discipline
337 338
Issue and bug management
338
Wikis RSS and IRC/chat systems Word processor documents Summary
339 340 341 341
Linking to the SCCS
339
Index
343
[ xi ]
This material is copyright and is licensed for the sole use by Paul Corcorran on 5th July 2009 8601 ave. p #1, , lubbock, , 79423
This material is copyright and is licensed for the sole use by Paul Corcorran on 5th July 2009 8601 ave. p #1, , lubbock, , 79423
Preface Struts 2.1 is a modern, extensible, agile web application framework, which is suitable for both small- and large-scale web applications. The book begins with a comprehensive look at the basics of Struts 2.1, interspersed with detours into more advanced development topics. You'll learn about configuring Struts 2.1 actions, results, and interceptors via both XML and Java annotations. You'll get an introduction to most of the Struts 2.1 custom tags, and also learn how they can assist in rapid application prototyping and development. From there, you'll make your way into Struts 2.1's strong support for form validation and type conversion, which allows you to treat your form values as domain objects without cluttering your code. A look at Struts 2.1's interceptors is the final piece of the Struts 2.1 puzzle, which allows you to leverage the standard Struts 2 interceptors, as well as implement your own custom behavior. After covering Struts 2.1, you'll journey into the world of JavaScript (a surprisingly capable language), the Document Object Model (DOM), and CSS, and learn how to create clean and concise client-side behavior. You'll leverage that knowledge as you move on to Struts 2 themes and templates, which give you a powerful way to encapsulate site-wide user interface behavior. The book closes with a look at some tools that make the application development life cycle easier to manage, particularly in a team environment, and more automatic.
What this book covers
Chapter 1 gives us a bird's-eye view of Struts 2 and examines some useful techniques of lightweight, agile development. Chapter 2 gives an introduction to Struts 2 application configuration, using both XML and annotations. It also covers the beginning of our sample application, RecipeBox.
This material is copyright and is licensed for the sole use by Paul Corcorran on 5th July 2009 8601 ave. p #1, , lubbock, , 79423
Preface
Chapter 3 covers some of the functionality provided by Struts 2's ActionSupport class, including I18N, and a first look at form validation. It also covers some basic RecipeBox functionality after gathering some user stories. Chapter 4 examines several common, standard Struts 2 result types. It also covers how to write our own custom result types. Chapter 5 gives an in-depth look at the generic Struts 2 custom tags. These include tags for iteration, list generation, conditionals, and internationalization (I18N). Chapter 6 continues our exploration of Struts 2 custom tags, focusing especially on its form tags. Chapter 7 examines Struts 2 form validation, including both XML and annotation-driven validation. It also teaches more about how Struts 2 converts our form values into domain objects, and shows how to create our own type converters to handle custom data types. Chapter 8 finishes our comprehensive introduction to Struts 2, by checking out the included Struts 2 interceptors. It also discusses how to write and configure our own interceptors. Chapter 9 looks at how to handle errors in Struts 2, as well as discusses error and exception handling in general. It also covers some general Java logging topics, focusing on using Apache Commons Logging and Log4J. Chapter 10 explores how to best leverage JavaScript and how to keep it modular. Chapter 11 covers the client-side functionality, which depends on more than JavaScript. By using CSS and the DOM effectively, we can accomplish a lot with a minimal amount of code. Chapter 12 covers Struts 2 themes and templates. The themes and templates in Struts 2 allow for application-wide functionality on the client side, keeping our JSP pages lightweight and adaptable. Rather than writing boilerplate HTML on our pages, we can separate it into themes and templates. Chapter 13 takes a look at some of Struts 2's built-in support for Ajax using the Dojo tags. It also covers the Struts 2 REST plug-in that furthers our "convention over configuration" path. Chapter 14 covers how to apply the TDD concepts to several testing aspects, including unit, functional, and acceptance tests.
[]
This material is copyright and is licensed for the sole use by Paul Corcorran on 5th July 2009 8601 ave. p #1, , lubbock, , 79423
Preface
Chapter 15 looks at many aspects of documentation, including "self-documenting" code, Javadocs, generators, methodologies, and so on, with a focus on automating as much documentation as possible.
What you need for this book
You'll need all the typical Java web application development tools. An IDE is very handy, but it doesn't matter which one you use. Almost any modern application server can be used to run the sample application. Having an Internet connection while reading is extremely useful. The Struts 2 download includes the documentation wiki, along with the XWork and Struts 2 API Javadocs. However, we may also need to reference the Servlet API, various library APIs, and so on. Having access to the Struts 2 user mailing list can also be very beneficial, as sometimes searching the web for a question is the quickest way to get it answered. The most important requirements aren't dependent on a particular Java version or specification. Curiosity, willingness to experiment, and patience will never be written up as a JSR, but they're critical qualities in a developer. It's perfectly fine to never learn the ins and outs of a framework. However, by digging into the documentation, and especially the source, we gain a much better understanding of why things happen the way they do. This increases our efficiency, our usefulness, and our value.
Who this book is for
This book is for Java developers who are interested in developing web applications using Struts. If you need a comprehensive introduction to Struts 2.1, along with the most important aspects of additional web application development technologies, agile programming practices, tool creation, and application life cycle management, this book is for you. You needn't know JavaScript and CSS to use this book, as the author will teach you the required basics. If you are a Struts 1 or WebWork user, and wish to go ahead and migrate to Struts 2, this is a perfectly practical guide for you.
Conventions
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning. []
This material is copyright and is licensed for the sole use by Paul Corcorran on 5th July 2009 8601 ave. p #1, , lubbock, , 79423
Preface
Code words in text are shown as follows: "ActionSupport is an XWork class that provides validation and default implementations of several common interfaces needed for I18N." A block of code will be set as follows: package com.packt.s2wad.ch03.actions.i18n; public class TextExamplesAction extends ActionSupport implements TextInterface { private static Log log = LogFactory.getLog(TextExamplesAction.class); public String execute() throws Exception { log.debug(getText("from.class.props")); return SUCCESS; } }
When we wish to draw your attention to a particular part of a code block, the relevant lines or items will be shown in bold: