/*
Title: Struts : Essential Skills (Essential Skills)
Authors: Steven Holzner
Publisher: McGraw-Hill Osborne Media
ISBN: 0072256591
*/
//ch07_01.jsp
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
Using <logic> Tags
Using <logic> Tags
Enter your data:
//ch07_04.jsp
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
Here's Your Data...
Here's Your Data...
The text field text:
Using <logic:empty name="ch07_03" property="empty">
Results: Empty
Using <logic:notEmpty name="ch07_03" property="text">
Results: Not empty
Using <logic:equal name="ch07_03" property="number" value="6">
Results: Equal
Using <logic:notEqual> name="ch07_03" property="number" value="7"
Results: Not equal
Using <logic:greaterEqual name="ch07_03" property="number" value="3">
Results: Greater than or equal
Using <logic:greaterThan name="ch07_03" property="number" value="4">
Results: Greater than
Using <logic:lessEqual name="ch07_03" property="number" value="8">
Results: Less than or equal
Using <logic:lessThan name="ch07_03" property="number" value="8">
Results: Less than
Using <logic:match name="ch07_03" property="text" value="6">
Results: Matched
Using <logic:notMatch name="ch07_03" property="number" value="9">
Results: No match
Using <logic:present name="ch07_03" property="number">
Results: Present
Using <logic:notPresent name="ch07_03" property="fish">
Results: Not present
//ch07_05.jsp
<%@ taglib uri="/tags/struts-html" prefix="html" %>
Using <bean> Tags
Using <bean> Tags
<%
Cookie cookie1 = new Cookie("message", "Hello!");
cookie1.setMaxAge(24 * 60 * 60);
response.addCookie(cookie1);
%>
Enter your data:
//ch07_08.jsp
<%@ page import="ch07.ch07_07" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
Here's Your Data...
Here's Your Data...
The text field text:
The cookie data:
<%= messageCookie.getValue() %>
The new variable:
<%= variable %>
The user-agent header data:
<%= headerObject %>
The parameter data:
<%= text %>
The mapping data:
<% String[] a = mapping.findForwards();
out.println(a[0]); %>
package ch07;
import org.apache.struts.action.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ch07_03 extends ActionForm
{
private String empty = "";
private String text = "";
private int number;
public String getEmpty()
{
return empty;
}
public void setEmpty(String text)
{
}
public String getText()
{
return text;
}
public void setText(String text)
{
this.text = text;
this.number = Integer.parseInt(text);
}
public int getNumber()
{
return number;
}
public void setNumber(int number)
{
this.number = number;
}
}
package ch07;
import java.io.*;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import org.apache.struts.action.*;
public class ch07_06 extends Action
{
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
return mapping.findForward("success");
}
}
package ch07;
import org.apache.struts.action.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ch07_07 extends ActionForm
{
private String text = "";
public String getText()
{
return text;
}
public void setText(String text)
{
this.text = text;
}
}
package ch07;
import java.io.*;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import org.apache.struts.action.*;
public class ch07_02 extends Action
{
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
return mapping.findForward("success");
}
}
Struts-Essential-Skills-ch07.zip( 1,456 k)