Book Image

Learning Jakarta Struts 1.2: a concise and practical tutorial

By : Stephan Wiesner
Book Image

Learning Jakarta Struts 1.2: a concise and practical tutorial

By: Stephan Wiesner

Overview of this book

<p>Jakarta Struts is an Open Source Java framework for developing web applications. By cleanly separating logic and presentation, Struts makes applications more manageable and maintainable.<br />Since its donation to the Apache Foundation&nbsp; in 2001, Struts has been rapidly accepted as the leading Java web application framework, and community support and development is well established.<br /><br />Struts-based web sites are built from the ground up to be easily modifiable and maintainable, and internationalization and flexibility of design are deeply rooted. Struts uses the Model-View-Controller design pattern to enforce a strict separation between processing logic and presentation logic, and enables efficient object re-use.<br /><br />The book is written as a structured tutorial, with each chapter building on the last. The book begins by introducing the architecture of a Struts application in terms of the Model-View-Controller pattern. Having explained how to install Jakarta and Struts, the book then goes straight into an initial implementation of the book store. The well structured code of the book store application is explained and related simply to the architectural issues.<br /><br />Custom Actions, internationalization and the possibilities offered by Taglibs are covered early to illustrate the power and flexibility inherent in the framework. The bookstore application is then enhanced in functionality and quality through the addition of logging and configuration data, and well-crafted forms. At each stage of enhancement, the design issues are laid out succinctly, then the practical implementation explained clearly. This combination of theory and practical example lays a solid understanding of both the principles and the practice of building Struts applications.</p>
Table of Contents (20 chapters)
Learning Jakarta Struts 1.2
Credits
Preface
About the Book
Glossary
Literature

Appendix A. Solutions

Chapter 2: Hello Struts

Exercise 1

1. How would you go about displaying French text?

You must create a new .properties file. This file will be named application_fr.properties. You can have access to the values in this file after a reload. Try this out, adjust the language settings of your browser and call the pages again.

2. How would you use text that spans multiple lines?

The properties files are built on a name-value schema. You cannot use a line break here directly. You can insert \n, but it won’t be displayed in HTML. Instead of this, you can use HTML elements, for example,<br>. But pay attention that you stay with HTML; it will become complex if you use XHTML. We will come across this in later chapters.

5. It was indicated in the chapter that English is the default language; is this correct? Swap the file names over: change application.properties to application_de.properties and vice versa. What happens now if you try to access the page using a preferred language that isn't supported? application.properties to application_de.properties

Whichever language you set in the application.properties file becomes the default language. This can be done using the file without a language extension (that is, without a language code in the name, like application_de.properties). It will be used if no other suitable file is found, for example, for a Spanish visitor.