Instructions
-
- 1
Create a new JSP page in a text editor or development application. Save the file into your project directory
- 2
Type "<%@ page language="java" %><%@ taglib uri="/WEB-INF/struts-layout.tld" prefix="layout" %><%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>". This is the standard header for a struts-layout JSP page. It declares the scripting language as Java and imports the necessary struts-html and struts-layout libraries.
-
- 3
Type "<layout:html>". This tag begins the layout declaration for creating HTML and is a required tag.
- 4
Type "<layout:form action="myAction">" to open a new form. Forms contain input methods that collect and process data from the user. "myAction" refers to a user-defined script that will process the input data. A login prompt with username, password and a submit button is a common example of a form.
- 5
Use the "<layout:text>," "<layout:password>," "<layout:date>" and the other form input tags to provide functionality to the web application. Each input option has individual properties that can be customized based on your project's needs. For example, typing "isRequired="true"" in a field declaration will place a red star next to it to signify its importance and require the field be completed before submitting.
- 6
Type "<layout:submit property="submit" value = "submit" />" to create a standard submit button. The submit button causes the form to process the input data and is a vital aspect of a form. A cancel button can also be created by using the "<layout:cancel>" tag. The "<layout:reset />" tag creates a button to clear all data in the input form.
- 7
Use the "<layout:row>" and "<layout:column>" tags to set up rows and columns similar to table structures in HTML. Rows contain a number of columns for easy distribution of information across a space. The size of the rows and columns can be set using the height and width properties.
- 1
Tips & Warnings
-
All the tags in struts-layout must be closed adding a closing tag. A closing tag is the name of the tag with a "/" in front of it. For example, the "<layout:html>" tag is closed with "</layout:html>." The closing order is based on the hierarchy of the elements.