Views as JSPs

Struts uses JavaServer Pages (JSPs) as view components.  they are normally used with several special-purpose JSP taglibs. Among other functions, the taglibs simplify the HTML specification of input components, such as TextFields, and automatically transfer data from them to a FormBean associated with the page.


Architecture



 


Example


<%@ page contentType="text/html; charset=Cp1252" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-nested" prefix="nested" %>

<html:html>

<%! String projectName = jbs.eb2c.util.Context.getProjectName(); %>

<head>
<META http-equiv='Content-Style-Type' content='text/css'>
<LINK href='/<%= projectName %>/theme/Master.css' rel='stylesheet' type='text/css'>
<title>eb2c login</title>
</head>	
	
<body>

<br>
<h1>
Welcome to MyStore
</h1>
<h3>Please login</h3>

<html:errors/>
	
<html:form action='/actionUserLogin' method='post'>

<table cellpadding='0' cellspacing='0' width='100%' border='0'>

<html:hidden property="collectionBeanId" />

<TBODY>
		
<tr>
<td align='right' width='20%'><b>Email: </b></td>
<TD align='left' width='60%'>
<html:text property="email" size="25" />
</TD>
</tr>

<tr>
<td align='right' width='20%'><b>Password: </b></td>
<TD align='left' width='60%'>
<html:password property="password" size="25" />
</TD>
</tr>

<tr>
<td align='left' width='20%'> </td>
</tr>

<tr>
<td align='right' width='20%'></td>
<td align='left' width='60%'>
<html:submit property = "userAction" value="Login" style="background-color: rgb(224, 250, 226)" />
</td>
</tr>

<tr>
<td align='left' width='20%'> </td>
</tr>

		
<tr>
<td align='right' width='20%'><b>Messages: </b></td>
<TD align='left' width='60%'>
<html:textarea property="message" rows="4" cols="25" /></TD>
</tr>

<tr>
<td align='left' width='20%'> </td>
</tr>
		
		
</TBODY>

</table>

</html:form>

</body>

</html:html>