struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brad Jones" <>
Subject [ActionError] Incorrect Value Displayed on jsp
Date Thu, 01 Aug 2002 21:31:42 GMT
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 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 

Jsp Page Code that calls the action (TestAction.jsp):
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

<META name="GENERATOR" content="IBM WebSphere Studio">

<html:form action="/TestAction">
	<html:text property="modelnumber"></html:text>
	<html:submit property="enter"></html:submit>


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" %>

<META name="GENERATOR" content="IBM WebSphere Studio">
System Error:&nbsp;<html:errors/>

Action Class that sets the error (
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 (
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
	 * 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;


  <!-- ========== Form Bean Definitions =================================== 

    <form-bean      name="TestForm"

  <!-- ========== Global Forward Definitions ============================== 
    <forward   	name="success"              	path="/ForceTest.jsp"/>
    <forward	name="error"					path="/ForceTestError.jsp"/>

  <!-- ========== Action Mapping Definitions ============================== 

    <action    path="/TestAction"

    <!-- 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"
    <action    path="/admin/addForward"
    <action    path="/admin/addMapping"
    <action    path="/admin/reload"
    <action    path="/admin/removeFormBean"
    <action    path="/admin/removeForward"
    <action    path="/admin/removeMapping"


</struts-config> 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 

error.first=First Error



MSN Photos is the easiest way to share and print your photos:

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message