/*
Title: Struts : Essential Skills (Essential Skills)
Authors: Steven Holzner
Publisher: McGraw-Hill Osborne Media
ISBN: 0072256591
*/
//index.jsp
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
A Welcome Page
A Sample Welcome Page
ERROR: Application resources not loaded -- check servlet container
logs for error messages.
Please click the button:
//result.jsp
A Results page
A Sample Results Page
<%= request.getAttribute("DATA") %>
package ch02;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.*;
public class DataForm extends ActionForm {
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
return new ActionErrors();
}
}
package ch02;
//import ch02.DataForm;
import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.struts.action.*;
public class DataAction extends Action {
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
String text = "No worries.";
String target = new String("success");
request.setAttribute("DATA", text);
return (mapping.findForward(target));
}
}
Struts-Essential-Skills-ch02.zip( 1,437 k)