Struts Tutorial Objective
- Understand the basics of creating web applications using struts
- Learn fundamentals of creating a web page in struts
- Learn how to use the bean and html tags in struts
- Work with a form bean to create a web form
- Use quick validation code to reduce false submits
Struts is a framework that provides a Controller servlet to make creating Model View Controller web sites easier. Struts has been gaining momentum for a few years and is now extremely popular. The Apache group manages struts. The popularity of struts and its easy to use nature make it an attractive addition to the many companies Java web strategy. Since it is open source and popular it is possible to see the code, and to contribute to the code base of struts.
In this chapter we will take a look at what it takes to make a web site using struts and see how you can get up and started on it really fast. This is an introductory level look at struts aimed at getting you started. Information will be provided on how to learn more and continue to build on the knowledge gained in this section.
History of Struts
- The introduction of Servlets changed how web pages were created.
- Servlets are faster, more robust and are portable compared to CGI scripting.
- Servlets evolved because endless out.println() statements in a servlet become problematic.
- JSP changes Servlets making them easier to create and more comfortable to code scriptors.
- JSPs swept the Java community because they are fast to create and allow HTMLers to understand the code (mostly).
- JSPs have trouble when too much Java is nesting into the HTML pages fail to have decent code reuse.
- Tag Libraries promise to help reduce the Java code, but most developers prefer not to create them.
- Tag Libraries are not the easiest things to create.
- Debugging Tag library can be a pain.
- One tag is not what most want, a set of good tags would be better.
- In 2000 Craig R. McClanahan launched Struts to create a set of tools that make creation of web sites using Java easier.
- Struts uses Servlets to provide non visual web site control code.
- Struts uses JSP to provide an easy way to create a presentation.
- Struts uses Tag Libraries to make the code in the JSP easier to write and to understand.
- Struts is a Model 2 or Model View Controller framework.
- A framework is a set of software components that provides architecture.
- You will add the business logic and presentation to the framework to create a web application.
- Using the Struts framework makes making web sites easier, especially if you want to make well designed maintainable sites.
- Using Struts presents you with a learning curve, you will need time and effort to get up and going on struts.
- You may not understand all the parts of struts on your first pass. Don’t worry it wasn’t created to be difficult to use.