I am trying to display an error message to the user on the jsp page. The Error is being set in my action and correctly retrieved from the ApplicationResources.properties file. The problem is that it's being displayed in the following fassion where First Error is the error that I'm trying to display: null First Error null. I can't figure out where the null's are coming from.
Here's my code if anyone has any suggestions that would be greatly appreciated: Jsp Page Code that calls the action (TestAction.jsp): <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <HTML> <HEAD> <META name="GENERATOR" content="IBM WebSphere Studio"> <TITLE>ForceTest.jsp</TITLE> </HEAD> <BODY> <html:form action="/TestAction"> <html:text property="modelnumber"></html:text> <html:submit property="enter"></html:submit> </html:form> </BODY> </HTML> Jsp Page Code that displays the error (TestActionError.jsp): <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <HTML> <HEAD> <META name="GENERATOR" content="IBM WebSphere Studio"> <TITLE>ForceTestError.jsp</TITLE> </HEAD> <BODY> System Error: <html:errors/> </BODY> </HTML> Action Class that sets the error (TestAction.java): import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.util.Locale; import java.util.Vector; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionServlet; import org.apache.struts.util.MessageResources; import org.apache.struts.util.PropertyUtils; public final class TestAction extends Action { public ActionForward perform(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { ActionErrors errors = new ActionErrors(); String webMessage = "error.first"; ActionError ae1 = new ActionError(webMessage); errors.add(ActionErrors.GLOBAL_ERROR, ae1); saveErrors(request, errors); return (mapping.findForward("error")); } } Action Form Code (TestForm.java): import javax.servlet.http.HttpServletRequest; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMapping; /** * STRUTS Action Form for Dealer Authenticate * @author Brad N. Jones (IBM Global Services) * @created 4/30/2002 */ public class TestForm extends ActionForm { private String modelnumber; public String getModelnumber(){ return this.modelnumber; } public void setModelnumber(String aModelnumber){ this.modelnumber = aModelnumber; } /** * Reset all properties to their default values. * @param mapping The mapping used to select this instance * @param request The servlet request we are processing * @return void */ public void reset(ActionMapping mapping, HttpServletRequest request) { } /** * Validate the properties that have been set from this HTTP request, * and return an <code>ActionErrors</code> object that encapsulates any * validation errors that have been found. If no errors are found, return * <code>null</code> or an <code>ActionErrors</code> object with no * recorded error messages. * * @param mapping The mapping used to select this instance * @param request The servlet request we are processing * @return ActionErrors org.apache.struts.action.ActionErrors */ public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); return errors; } } struts-config.xml: <struts-config> <!-- ========== Form Bean Definitions =================================== --> <form-beans> <form-bean name="TestForm" type="com.ibm.us.fcdds.struts.form.TestForm"/> </form-beans> <!-- ========== Global Forward Definitions ============================== --> <global-forwards> <forward name="success" path="/ForceTest.jsp"/> <forward name="error" path="/ForceTestError.jsp"/> </global-forwards> <!-- ========== Action Mapping Definitions ============================== --> <action-mappings> <action path="/TestAction" type="com.ibm.us.fcdds.struts.action.TestAction" name="TestForm" scope="request" input="/ForceTest.jsp"> </action> <!-- The standard administrative actions available with Struts --> <!-- These would be either omitted or protected by security --> <!-- in a real application deployment --> <action path="/admin/addFormBean" type="org.apache.struts.actions.AddFormBeanAction"/> <action path="/admin/addForward" type="org.apache.struts.actions.AddForwardAction"/> <action path="/admin/addMapping" type="org.apache.struts.actions.AddMappingAction"/> <action path="/admin/reload" type="org.apache.struts.actions.ReloadAction"/> <action path="/admin/removeFormBean" type="org.apache.struts.actions.RemoveFormBeanAction"/> <action path="/admin/removeForward" type="org.apache.struts.actions.RemoveForwardAction"/> <action path="/admin/removeMapping" type="org.apache.struts.actions.RemoveMappingAction"/> </action-mappings> </struts-config> ApplicationResources.properties Code: index.title=Struts Starter Application index.heading=Hello World! index.message=To get started on your own application, copy the struts-blank.war to a new WAR file using the name for your application. Place it in your container's "webapp" folder (or equivalent), and let your container auto-deploy the application. Edit the skeleton configuration files as needed, reload Struts or restart your container, and you are on your way! (You can find the ApplicationResources file with this message in the classes folder.) error.first=First Error Thanks, Brad _________________________________________________________________ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>