MessageResources in Struts

Hello
in struts App. message for key can not be fund ???
tools
struts 1.2.9
tomcat 5.5.17
Eclipse 3.0
// web.xml
<!-- Action Servlet Configuration -->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/conf/struts-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
// Struts-config.xml
<message-resources parameter="resources.ApplicationResources"/>
I have an ApplicationResources_en.properties file located here:
\WEB-INF\classes\resources\ApplicationResources_en.properties
in ApplicationResources_en.properties
app.title = Hello Guys
//I becom an Exception
org.apache.jasper.JasperException: Missing message for key "app.title"
what is wrong

When "en" is selected, it will try to load AppResources not AppResources_en

Similar Messages

  • Problems with struts MessageResources.properties files

    hi,
    I am a newbie in using struts. I have the following resources.
    Resources:
    java:j2sdk1.4.X
    struts:1.2.4
    webserver:tomcat 5
    jsp:2.0
    servlets:2.4
    IDE:Ecilipse 3.0 IDE
    Problem: I have copied the struts_blank.war file into tomcat webapps dir. Inside Ecilipse I create a new project and import the struts_blank.war file into the project. I type the URL (http://localhost:8080/proj_struts/Welcome.do)and it works file. However if i create any formbeans or any other java classes, the MessageResources.properties file gets deleted from my classes folder in my dir. What am i doing wrong. Is there any plugin for struts for Ecilipse.
    Questions:
    to be specific, where should/which folder should these .properties files be located. Should they be in classes or src folder under WEBINF?. I have seen the entry in strutsconfig.xml file. All it has is the following element relating to .properties.
    Fixes tried:
    I tried copying the MessageResources.properties file into the sources folder
    but i am not sure how to configure the Eclipse so that it reads the .properties file file from src folder insted of classes. I am definately sure thisis a dumb sol..but i donno wht else to do....
    <!-- ======================================== Message Resources Definitions -->
    <message-resources parameter="MessageResources" />
    It doesnt even say where is it looking(which folder).....
    Could some one throw some light on this issue and guide me thru this ordeal
    Regards
    AK

    Problem: I have copied the struts_blank.war file into
    tomcat webapps dir. Inside Ecilipse I create a new
    project and import the struts_blank.war file into the
    project. I type the URL
    (http://localhost:8080/proj_struts/Welcome.do)and it
    works file. However if i create any formbeans or any
    other java classes, the MessageResources.properties
    file gets deleted from my classes folder in my dir.No idea why this should happen.
    What am i doing wrong. Is there any plugin for struts
    for Ecilipse. http://easystruts.sourceforge.net/
    Questions:
    to be specific, where should/which folder should
    these .properties files be located. Should they be in
    classes or src folder under WEBINF?. I have seen the
    entry in strutsconfig.xml file. All it has is the
    following element relating to .properties.WEB-INF/classes, if nothing is specified :)
    Fixes tried:
    I tried copying the MessageResources.properties file
    into the sources folder
    but i am not sure how to configure the Eclipse so
    that it reads the .properties file file from src
    folder insted of classes. I am definately sure thisis
    a dumb sol..but i donno wht else to do....This solution may not be so dumb after all. The only thing you missed out was that Eclipse doesn't copy any files other than classes. Maybe a custom Ant script would have done such a trick :)
    <!-- ======================================== Message
    Resources Definitions -->
    <message-resources parameter="MessageResources"
    ces" />
    It doesnt even say where is it looking(which
    folder).....As I said earlier, it's looking in WEB-INF/classes

  • Why dynamic table creation with struts working only for JDK1.3.1_02 version

    Row
    import java.util.Vector;
    public class Row
    private static int colsize;
    private Column[] columns;
    public void setColumns(Column[] columns)
    System.out.println("SetColumns");
    this.columns = columns;
    public void setColumn(int i, Column column)
         System.out.println("setting"+ i+"th column"+column);
    public Column[] getColumns()
    return null;
    public Column getColumns(int i)
    System.out.println("Column"+i);
    System.out.println("Colsize"+colsize);
    if(columns == null)
    columns= new Column[colsize];
    if(columns[i] == null)
    columns[i] = new Column();
    return columns;
    public int getColsize()
         return colsize;
    public static void setColsize(int size)
         colsize = size;
    Column:
    public class Column
    private String value;
    public void setValue(String value)
    System.out.println("Value="+value);
    this.value = value;
    public String getValue()
    return value;
    ApplicationResources:
    button.cancel=Cancel
    button.confirm=Confirm
    button.reset=Reset
    button.save=Save
    database.load=Cannot load database from {0}
    error.database.missing=<li>User database is missing, cannot validate logon credentials</li>
    error.fromAddress.format=<li>Invalid format for From Address</li>
    error.fromAddress.required=<li>From Address is required</li>
    error.fullName.required=<li>Full Name is required</li>
    error.host.required=<li>Mail Server is required</li>
    error.noSubscription=<li>No Subscription bean in user session</li>
    error.password.required=<li>Password is required</li>
    error.password2.required=<li>Confirmation password is required</li>
    error.password.match=<li>Password and confirmation password must match</li>
    error.password.mismatch=<li>Invalid username and/or password, please try again</li>
    error.replyToAddress.format=<li>Invalid format for Reply To Address</li>
    error.transaction.token=<li>Cannot submit this form out of order</li>
    error.type.invalid=<li>Server Type must be 'imap' or 'pop3'</li>
    error.type.required=<li>Server Type is required</li>
    error.username.required=<li>Username is required</li>
    error.username.unique=<li>That username is already in use - please select another</li>
    errors.footer=</ul><hr>
    errors.header=<h3><font color="red">Validation Error</font></h3>You must correct the following error(s) before proceeding:<ul>
    errors.ioException=I/O exception rendering error messages: {0}
    heading.autoConnect=Auto
    heading.subscriptions=Current Subscriptions
    heading.host=Host Name
    heading.user=User Name
    heading.type=Server Type
    heading.action=Action
    index.heading=MailReader Demonstration Application Options
    index.logon=Log on to the MailReader Demonstration Application
    index.registration=Register with the MailReader Demonstration Application
    index.title=MailReader Demonstration Application (Struts 1.0-b1)
    index.tour=A Walking Tour of the Example Application
    linkSubscription.io=I/O Error: {0}
    linkSubscription.noSubscription=No subscription under attribute {0}
    linkUser.io=I/O Error: {0}
    linkUser.noUser=No user under attribute {0}
    logon.title=MailReader Demonstration Application - Logon
    mainMenu.heading=Main Menu Options for
    mainMenu.logoff=Log off MailReader Demonstration Application
    mainMenu.registration=Edit your user registration profile
    mainMenu.title=MailReader Demonstration Application - Main Menu
    option.imap=IMAP Protocol
    option.pop3=POP3 Protocol
    prompt.autoConnect=Auto Connect:
    prompt.fromAddress=From Address:
    prompt.fullName=Full Name:
    prompt.mailHostname=Mail Server:
    prompt.mailPassword=Mail Password:
    prompt.mailServerType=Server Type:
    prompt.mailUsername=Mail Username:
    prompt.password=Password:
    prompt.password2=(Repeat) Password:
    prompt.replyToAddress=Reply To Address:
    prompt.username=Username:
    registration.addSubscription=Add
    registration.deleteSubscription=Delete
    registration.editSubscription=Edit
    registration.title.create=Register for the MailReader Demostration Application
    registration.title.edit=Edit Registration for the MailReader Demonstration Application
    subscription.title.create=Create New Mail Subscription
    subscription.title.delete=Delete Existing Mail Subscription
    subscription.title.edit=Edit Existing Mail Subscription
    LogonForm
    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;
    public class LogonForm extends ActionForm
    private String username;
    private String password;
    private String errors;
    public String getUsername()
    return username;
    public void setUsername(String username)
    this.username = username;
    public void setPassword(String password)
    this.password = password;
    public String getPassword()
    return password;
    public String getErrors()
         return errors;
    public void setErrors(String errors)
         this.errors = errors;
    public ActionErrors validate(ActionMapping mapping,
    HttpServletRequest request) {
    ActionErrors errors = new ActionErrors();
    if ((username == null) || (username.length() < 1))
    errors.add("username", new ActionError("error.username.required"));
    if ((password == null) || (password.length() < 1))
    errors.add("password", new ActionError("error.password.required"));
    return errors;
    TableForm
    import org.apache.struts.action.ActionForm;
    import java.util.Vector;
    public class TableForm extends ActionForm
    private static int rowsize;
    private Row[] rows;
    public Row getRows(int i)
    System.out.println("Row"+i);
    System.out.println("Rowsize"+rowsize);
    if(rows == null)
    rows = new Row[rowsize];
    if(rows[i] == null)
    rows[i] = new Row();
    return rows[i];
    public Row[] getRows()
         return null;
    public void setRows(Row[] rows)
         System.out.println("SetRows");
         // this.rows=rows;
    public static void setRowsize(int size)
         rowsize = size;
    public int getRowSize()
         return rowsize;
    LogonAction
    import java.io.IOException;
    import java.util.Hashtable;
    import java.util.Locale;
    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.ActionError;
    import org.apache.struts.action.ActionErrors;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.action.ActionServlet;
    import org.apache.struts.util.MessageResources;
    public class LogonAction extends Action
    public ActionForward execute(ActionMapping mapping,
                        ActionForm form,
                        HttpServletRequest request,
                        HttpServletResponse response)
         throws IOException, ServletException {
    LogonForm logonForm = (LogonForm) form;
    System.out.println(logonForm);
    System.out.println(logonForm.getUsername());
    System.out.println(logonForm.getPassword());
    if(logonForm.getUsername().equals("test") && logonForm.getPassword().equals("test"))
    //TableForm tform = new TableForm();
    //tform.setRowsize(2);
    //tform.getRows(0).setColsize(2);
    //tform.getRows(1).setColsize(2);
    //request.getSession().setAttribute("tableForm",tform);
         System.out.println("Table Form setRowSize");
    TableForm.setRowsize(2);
         System.out.println("Table Form set ColSize");
    Row.setColsize(2);
         System.out.println("Returning success");
    return mapping.findForward("success");
    else
              ActionErrors errors = new ActionErrors();
              errors.add("password",
    new ActionError("error.password.mismatch"));
    saveErrors(request, errors);
    //logonForm.setErrors("LoginError");
    return mapping.findForward("failure");
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE struts-config PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
    "http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">
    <!--
    This is the Struts configuration file for the example application,
    using the proposed new syntax.
    NOTE: You would only flesh out the details in the "form-bean"
    declarations if you had a generator tool that used them to create
    the corresponding Java classes for you. Otherwise, you would
    need only the "form-bean" element itself, with the corresponding
    "name" and "type" attributes.
    -->
    <struts-config>
    <form-beans>
    <!-- Logon form bean -->
    <form-bean name="logonForm"
    type="LogonForm"/>
    <form-bean name="tableForm"
    type="TableForm"/>
    <form-bean name="profileForm"
    type="ProfileForm"/>
    </form-beans>
    <global-forwards>
    <forward name="success" path="/Profile.jsp"/>
    </global-forwards>
    <!-- ========== Action Mapping Definitions ============================== -->
    <action-mappings>
    <!-- Edit user registration -->
    <action path="/logon"
    type="LogonAction"
    name="logonForm"
    scope="request"
    validate="false"
    input="/Test.jsp">
    <forward name="success" path="/Table.jsp"/>
    <forward name="failure" path="/Test.jsp"/>
    </action>
    <action path="/table"
    type="TableAction"
    name="tableForm"
    scope="request"
    validate="false">
    <forward name="success" path="/Bean.jsp"/>
    <forward name="failure" path="/Table.jsp"/>
    </action>
    <action path="/profile"
    type="ProfileAction"
    name="profileForm"
    scope="request"
    validate="false"
    parameter="method">
    <forward name="edit" path="/EditProfile.jsp"/>
    <forward name="show" path="/Profile.jsp"/>
    </action>
    </action-mappings>
    </struts-config>
    Test.jsp
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <html:html locale="true">
    <html:form action="/logon" >
    <center>
    <table>
    <tr>
    <td> Username </td>
    <td> <html:text property="username" size="16" maxlength="16"/> </td>
    <td> <html:errors property="username" /> </td>
    </tr>
    <tr>
    <td> Password </td>
    <td> <html:password property="password" size="16" maxlength="16"
    redisplay="false"/> </td>
    <td><html:errors property="password" /> </td>
    </tr>
    </table>
    </center>
    <center> <html:submit property="submit" value="Submit"/> </center>
    </html:form>
    </html:html>
    Table.jsp
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <html:html locale="true">
    <html:form action="/table" >
    <center>
    <table>
    <tr>
    <td> <html:text property="rows[0].columns[0].value" /> </td>
    <td> <html:text property="rows[0].columns[1].value" /></td>
    </tr>
    <tr>
    <td> <html:text property="rows[1].columns[0].value" /> </td>
    <td> <html:text property="rows[1].columns[1].value" /></td>
    </tr>
    </table>
    </center>
    <center> <html:submit property="submit" value="Submit"/> </center>
    </html:form>
    </html:html>

    The above application runs only with JDK1.3.1_02 and not with any other version. This application is creating dynamic table using struts.
    Can anybody help me on the same
    also appending web.xml contents:
    <?xml version="1.0" ?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    <!-- Action Servlet Configuration -->
    <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
    <param-name>application</param-name>
    <param-value>ApplicationResources</param-value>
    </init-param>
    <init-param>
    <param-name>config</param-name>
    <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
    <init-param>
    <param-name>debug</param-name>
    <param-value>2</param-value>
    </init-param>
    <init-param>
    <param-name>detail</param-name>
    <param-value>2</param-value>
    </init-param>
    <init-param>
    <param-name>validate</param-name>
    <param-value>true</param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
    </servlet>
    <!-- Action Servlet Mapping -->
    <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
    </servlet-mapping>
    <!--Welcome file list starts here -->
    <welcome-file-list>
    <welcome-file>
    /test.jsp
    </welcome-file>
    </welcome-file-list>
    <!-- Struts Tag Library Descriptors -->
    <taglib>
    <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
    <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
    <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
    <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
    </taglib>
    </web-app>
    validate-rules.xml
    <!DOCTYPE form-validation PUBLIC
    "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.0//EN"
    "http://jakarta.apache.org/commons/dtds/validator_1_0.dtd">
    <!--
    This file contains the default Struts Validator pluggable validator
    definitions. It should be placed somewhere under /WEB-INF and
    referenced in the struts-config.xml under the plug-in element
    for the ValidatorPlugIn.
    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
    <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,
    /WEB-INF/validation.xml"/>
    </plug-in>
    These are the default error messages associated with
    each validator defined in this file. They should be
    added to your projects ApplicationResources.properties
    file or you can associate new ones by modifying the
    pluggable validators msg attributes in this file.
    # Struts Validator Error Messages
    errors.required={0} is required.
    errors.minlength={0} can not be less than {1} characters.
    errors.maxlength={0} can not be greater than {1} characters.
    errors.invalid={0} is invalid.
    errors.byte={0} must be a byte.
    errors.short={0} must be a short.
    errors.integer={0} must be an integer.
    errors.long={0} must be a long.
    errors.float={0} must be a float.
    errors.double={0} must be a double.
    errors.date={0} is not a date.
    errors.range={0} is not in the range {1} through {2}.
    errors.creditcard={0} is an invalid credit card number.
    errors.email={0} is an invalid e-mail address.
    -->
    <form-validation>
    <global>
    <validator name="required"
    classname="org.apache.struts.validator.FieldChecks"
    method="validateRequired"
    methodParams="java.lang.Object,
    org.apache.commons.validator.ValidatorAction,
    org.apache.commons.validator.Field,
    org.apache.struts.action.ActionErrors,
    javax.servlet.http.HttpServletRequest"
    msg="errors.required">
    <javascript><![CDATA[
    function validateRequired(form) {
    var isValid = true;
    var focusField = null;
    var i = 0;
    var fields = new Array();
    oRequired = new required();
    for (x in oRequired) {
         var field = form[oRequired[x][0]];
    if (field.type == 'text' ||
    field.type == 'textarea' ||
    field.type == 'file' ||
    field.type == 'select-one' ||
    field.type == 'radio' ||
    field.type == 'password') {
    var value = '';
                                  // get field's value
                                  if (field.type == "select-one") {
                                       var si = field.selectedIndex;
                                       if (si >= 0) {
                                            value = field.options[si].value;
                                  } else {
                                       value = field.value;
    if (trim(value).length == 0) {
         if (i == 0) {
         focusField = field;
         fields[i++] = oRequired[x][1];
         isValid = false;
    if (fields.length > 0) {
    focusField.focus();
    alert(fields.join('\n'));
    return isValid;
    // Trim whitespace from left and right sides of s.
    function trim(s) {
    return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
    ]]>
    </javascript>
    </validator>
    <validator name="requiredif"
    classname="org.apache.struts.validator.FieldChecks"
    method="validateRequiredIf"
    methodParams="java.lang.Object,
    org.apache.commons.validator.ValidatorAction,
    org.apache.commons.validator.Field,
    org.apache.struts.action.ActionErrors,
    org.apache.commons.validator.Validator,
    javax.servlet.http.HttpServletRequest"
    msg="errors.required">
    </validator>
    <validator name="minlength"
    classname="org.apache.struts.validator.FieldChecks"
    method="validateMinLength"
    methodParams="java.lang.Object,
    org.apache.commons.validator.ValidatorAction,
    org.apache.commons.validator.Field,
    org.apache.struts.action.ActionErrors,
    javax.servlet.http.HttpServletRequest"
    depends=""
    msg="errors.minlength">
    <javascript><![CDATA[
    function validateMinLength(form) {
    var isValid = true;
    var focusField = null;
    var i = 0;
    var fields = new Array();
    oMinLength = new minlength();
    for (x in oMinLength) {
    var field = form[oMinLength[x][0]];
    if (field.type == 'text' ||
    field.type == 'textarea') {
    var iMin = parseInt(oMinLength[x][2]("minlength"));
    if ((trim(field.value).length > 0) && (field.value.length < iMin)) {
    if (i == 0) {
    focusField = field;
    fields[i++] = oMinLength[x][1];
    isValid = false;
    if (fields.length > 0) {
    focusField.focus();
    alert(fields.join('\n'));
    return isValid;
    }]]>
    </javascript>
    </validator>
    <validator name="maxlength"
    classname="org.apache.struts.validator.FieldChecks"
    method="validateMaxLength"
    methodParams="java.lang.Object,
    org.apache.commons.validator.ValidatorAction,
    org.apache.commons.validator.Field,
    org.apache.struts.action.ActionErrors,
    javax.servlet.http.HttpServletRequest"
    depends=""
    msg="errors.maxlength">
    <javascript><![CDATA[
    function validateMaxLength(form) {
    var isValid = true;
    var focusField = null;
    var i = 0;
    var fields = new Array();
    oMaxLength = new maxlength();
    for (x in oMaxLength) {
    var field = form[oMaxLength[x][0]];
    if (field.type == 'text' ||
    field.type == 'textarea') {
    var iMax = parseInt(oMaxLength[x][2]("maxlength"));
    if (field.value.length > iMax) {
    if (i == 0) {
    focusField = field;
    fields[i++] = oMaxLength[x][1];
    isValid = false;
    if (fields.length > 0) {
    focusField.focus();
    alert(fields.join('\n'));
    return isValid;
    }]]>
    </javascript>
    </validator>
    <validator name="mask"
    classname="org.apache.struts.validator.FieldChecks"
    method="validateMask"
    methodParams="java.lang.Object,
    org.apache.commons.validator.ValidatorAction,
    org.apache.commons.validator.Field,
    org.apache.struts.action.ActionErrors,
    javax.servlet.http.HttpServletRequest"
    depends=""
    msg="errors.invalid">
    <javascript><![CDATA[
    function validateMask(form) {
    var isValid = true;
    var focusField = null;
    var i = 0;
    var fields = new Array();
    oMasked = new mask();
    for (x in oMasked) {
    var field = form[oMasked[x][0]];
    if ((field.type == 'text' ||
    field.type == 'textarea') &&
    (field.value.length > 0)) {
    if (!matchPattern(field.value, oMasked[x][2]("mask"))) {
    if (i == 0) {
    focusField = field;
    fields[i++] = oMasked[x][1];
    isValid = false;
    if (fields.length > 0) {
    focusField.focus();
    alert(fields.join('\n'));
    return isValid;
    function matchPattern(value, mask) {
    return mask.exec(value);
    }]]>
    </javascript>
    </validator>
    <validator name="byte"
    classname="org.apache.struts.validator.FieldChecks"
    method="validateByte"
    methodParams="java.lang.Object,
    org.apache.commons.validator.ValidatorAction,
    org.apache.commons.validator.Field,
    org.apache.struts.action.ActionErrors,
    javax.servlet.http.HttpServletRequest"
    depends=""
    msg="errors.byte"
    jsFunctionName="ByteValidations">
    <javascript><![CDATA[
    function validateByte(form) {
    var bValid = true;
    var focusField = null;
    var i = 0;
    var fields = new Array();
    oByte = new ByteValidations();
    for (x in oByte) {
         var field = form[oByte[x][0]];
    if (field.type == 'text' ||
    field.type == 'textarea' ||
    field.type == 'select-one' ||
                                  field.type == 'radio') {
                                  var value = '';
                                  // get field's value
                                  if (field.type == "select-one") {
                                       var si = field.selectedIndex;
                                       if (si >= 0) {
                                            value = field.options[si].value;
                                  } else {
                                       value = field.value;
    if (value.length > 0) {
    if (!isAllDigits(value)) {
    bValid = false;
    if (i == 0) {
    focusField = field;
    fields[i++] = oByte[x][1];
    } else {
         var iValue = parseInt(value);
         if (isNaN(iValue) || !(iValue >= -128 && iValue <= 127)) {
         if (i == 0) {
         focusField = field;
         fields[i++] = oByte[x][1];
         bValid = false;
    if (fields.length > 0) {
    focusField.focus();
    alert(fields.join('\n'));
    return bValid;
    }]]>
    </javascript>
    </validator>
    <validator name="short"
    classname="org.apache.struts.validator.FieldChecks"
    method="validateShort"
    methodParams="java.lang.Object,
    org.apache.commons.validator.ValidatorAction,
    org.apache.commons.validator.Field,
    org.apache.struts.action.ActionErrors,
    javax.servlet.http.HttpServletRequest"
    depends=""
    msg="errors.short"
    jsFunctionName="ShortValidations">
    <javascript><![CDATA[
    function validateShort(form) {
    var bValid = true;
    var focusField = null;
    var i = 0;
    var fields = new Array();
    oShort = new ShortValidations();
    for (x in oShort) {
         var field = form[oShort[x][0]];
    if (field.type == 'text' ||
    field.type == 'textarea' ||
    field.type == 'select-one' ||
    field.type == 'radio') {
    var value = '';
                                  // get field's value
                                  if (field.type == "select-one") {
                                       var si = field.selectedIndex;
                                       if (si >= 0) {
                                            value = field.options[si].value;
                                  } else {
                                       value = field.value;
    if (value.length > 0) {
    if (!isAllDigits(value)) {
    bValid = false;
    if (i == 0) {
    focusField = field;
    fields[i++] = oShort[x][1];
    } else {
         var iValue = parseInt(value);
         if (isNaN(iValue) || !(iValue >= -32768 && iValue <= 32767)) {
         if (i == 0) {
         focusField = field;
         fields[i++] = oShort[x][1];
         bValid = false;
    if (fields.length > 0) {
    focusField.focus();
    alert(fields.join('\n'));
    return bValid;
    }]]>
    </javascript>
    </validator>
    <validator name="integer"
    classname="org.apache.struts.validator.FieldChecks"
    method="validateInteger"
    methodParams="java.lang.Object,
    org.apache.commons.validator.ValidatorAction,
    org.apache.commons.validator.Field,
    org.apache.struts.action.ActionErrors,
    javax.servlet.http.HttpServletRequest"
    depends=""
    msg="errors.integer"
    jsFunctionName="IntegerValidations">
    <javascript><![CDATA[
    function validateInteger(form) {
    var bValid = true;
    var focusField = null;
    var i = 0;
    var fields = new Array();
    oInteger = new IntegerValidations();
    for (x in oInteger) {
         var field = form[oInteger[x][0]];
    if (field.type == 'text' ||
    field.type == 'textarea' ||
    field.type == 'select-one' ||
    field.type == 'radio') {
    var value = '';
                                  // get field's value
                                  if (field.type == "select-one") {
                                       var si = field.selectedIndex;
                                  if (si >= 0) {
                                       value = field.options[si].value;
                                  } else {
                                       value = field.value;
    if (value.length > 0) {
    if (!isAllDigits(value)) {
    bValid = false;
    if (i == 0) {
         focusField = field;
                                  fields[i++] = oInteger[x][1];
    } else {
         var iValue = parseInt(value);
         if (isNaN(iValue) || !(iValue >= -2147483648 && iValue <= 2147483647)) {
         if (i == 0) {
         focusField = field;
         fields[i++] = oInteger[x][1];
         bValid = false;
    if (fields.length > 0) {
    focusField.focus();
    alert(fields.join('\n'));
    return bValid;
    function isAllDigits(argvalue) {
    argvalue = argvalue.toString();
    var validChars = "0123456789";
    var startFrom = 0;
    if (argvalue.substring(0, 2) == "0x") {
    validChars = "0123456789abcdefABCDEF";
    startFrom = 2;
    } else if (argvalue.charAt(0) == "0") {
    validChars = "01234567";
    startFrom = 1;
    } else if (argvalue.charAt(0) == "-") {
    startFrom = 1;
    for (var n = startFrom; n < argvalue.length; n++) {
    if (validChars.indexOf(argvalue.substring(n, n+1)) == -1) return false;
    return true;
    }]]>
    </javascript>
    </validator>
    <validator name="long"
    classname="org.apache.struts.validator.FieldChecks"
    method="validateLong"
    methodParams="java.lang.Object,
    org.apache.commons.validator.ValidatorAction,
    org.apache.commons.validator.Field,
    org.apache.struts.action.ActionErrors,
    javax.servlet.http.HttpServletRequest"
    depends=""
    msg="errors.long"/>
    <validator name="float"
    classname="org.apache.struts.validator.FieldChecks"
    method="validateFloat"
    methodParams="java.lang.Object,
    org.apache.commons.validator.ValidatorAction,
    org.apache.commons.validator.Field,
    org.apache.struts.action.ActionErrors,
    javax.servlet.http.HttpServletRequest"
    depends=""
    msg="errors.float"
    jsFunctionName="FloatValidations">
    <javascript><![CDATA[
    function validateFloat(form) {
    var bValid = true;
    var focusField = null;
    var i = 0;
    var fields = new Array();
    oFloat = new FloatValidations();
    for (x in oFloat) {
         var field = form[oFloat[x][0]];
    if (field.type == 'text' ||
    field.type == 'textarea' ||
    field.type == 'select-one' ||
    field.type == 'radio') {
         var value = '';
                                  // get field's value
                                  if (field.type == "select-one") {
                                       var si = field.selectedIndex;
                                       if (si >= 0) {
                                       value = field.options[si].value;
                                  } else {
                                       value = field.value;
    if (value.length > 0) {
    // remove '.' before checking digits
    var tempArray = value.split('.');
    var joinedString= tempArray.join('');
    if (!isAllDigits(joinedString)) {
    bValid = false;
    if (i == 0) {
    focusField = field;
    fields[i++] = oFloat[x][1];
    } else {
         var iValue = parseFloat(value);
         if (isNaN(iValue)) {
         if (i == 0) {
         focusField = field;
         fields[i++] = oFloat[x][1];
         bValid = false;
    if (fields.length > 0) {
    focusField.focus();
    alert(fields.join('\n'));
    return bValid;
    }]]>
    </javascript>
    </validator>
    <validator name="double"
    classname="org.apache.struts.validator.FieldChecks"
    method="validateDouble"
    methodParams="java.lang.Object,
    org.apache.commons.validator.ValidatorAction,
    org.apache.commons.validator.Field,
    org.apache.struts.action.ActionErrors,
    javax.servlet.http.HttpServletRequest"
    depends=""
    msg="errors.double"/>
    <validator name="date"
    classname="org.apache.struts.validator.FieldChecks"
    method="validateDate"
    methodParams="java.lang.Object,
    org.apache.commons.validator.ValidatorAction,
    org.apache.commons.validator.Field,
    org.apache.struts.action.ActionErrors,
    javax.servlet.http.HttpServletRequest"
    depends=""
    msg="errors.date"
    jsFunctionName="DateValidations">
    <javascript><![CDATA[
    function validateDate(form) {
    var bValid = true;
    var focusField = null;
    var i = 0;
    var fields = new Array();
    oDate = new DateValidations();
    for (x in oDate) {
    var value = form[oDate[x][0]].value;
    var datePattern = oDate[x][2]("datePatternStrict");
    if ((form[oDate[x][0]].type == 'text' ||
    form[oDate[x][0]].type == 'textarea') &&
    (value.length > 0) &&
    (datePattern.length > 0)) {
    var MONTH = "MM";
    var DAY = "dd";
    var YEAR = "yyyy";
    var orderMonth = datePattern.indexOf(MONTH);
    var orderDay = datePattern.indexOf(DAY);
    var orderYear = datePattern.indexOf(YEAR);
    if ((orderDay < orderYear && orderDay > orderMonth)) {
    var iDelim1 = orderMonth + MONTH.length;
    var iDelim2 = orderDay + DAY.length;
    var delim1 = datePattern.substring(iDelim1, iDelim1 + 1);
    var delim2 = datePattern.substring(iDelim2, iDelim2 + 1);
    if (iDelim1 == orderDay && iDelim2 == orderYear) {
    dateRegexp = new RegExp("^(\\d{2})(\\d{2})(\\d{4})$");
    } else if (iDelim1 == orderDay) {
    dateRegexp = new RegExp("^(\\d{2})(\\d{2})[" + delim2 + "](\\d{4})$");
    } else if (iDelim2 == orderYear) {
    dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})(\\d{4})$");
    } else {
    dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})[" + delim2 + "](\\d{4})$");
    var matched = dateRegexp.exec(value);
    if(matched != null) {
    if (!isValidDate(matched[2], matched[1], matched[3])) {
    if (i == 0) {
    focusField = form[oDate[x][0]];
    fields[i++] = oDate[x][1];
    bValid = false;
    } else {
    if (i == 0) {
    focusField = form[oDate[x][0]];
    fields[i++] = oDate[x][1];
    bValid = false;
    } else if ((orderMonth < orderYear && orderMonth > orderDay)) {
    var iDelim1 = orderDay + DAY.length;
    var iDelim2 = orderMonth + MONTH.length;
    var delim1 = datePattern.substring(iDelim1, iDelim1 + 1);
    var delim2 = datePattern.substring(iDelim2, iDelim2 + 1);
    if (iDelim1 == orderMonth && iDelim2 == orderYear) {
    dateRegexp = new RegExp("^(\\d{2})(\\d{2})(\\d{4})$");
    } else if (iDelim1 == orderMonth) {
    dateRegexp = new RegExp("^(\\d{2})(\\d{2})[" + delim2 + "](\\d{4})$");
    } else if (iDelim2 == orderYear) {
    dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})(\\d{4})$");
    } else {
    dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})[" + delim2 + "](\\d{4})$");
    var matched = dateRegexp.exec(value);
    if(matched != null) {
    if (!isValidDate(matched[1], matched[2], matched[3])) {
    if (i == 0) {
    focusField = form[oDate[x][0]];
    fields[i++] = oDate[x][1];
    bValid = false;
    } else {
    if (i == 0) {
    focusField = form[oDate[x][0]];
    fields[i++] = oDate[x][1];
    bValid = false;
    } else if ((orderMonth > orderYear && orderMonth < orderDay)) {
    var iDelim1 = orderYear + YEAR.length;
    var iDelim2 = orderMonth + MONTH.length;
    var delim1 = datePattern.substring(iDelim1, iDelim1 + 1);
    var delim2 = datePattern.substring(iDelim2, iDelim2 + 1);
    if (iDelim1 == orderMonth && iDelim2 == orderDay) {
    dateRegexp = new RegExp("^(\\d{4})(\\d{2})(\\d{2})$");
    } else if (iDelim1 == orderMonth) {
    dateRegexp = new RegExp("^(\\d{4})(\\d{2})[" + delim2 + "](\\d{2})$");
    } else if (iDelim2 == orderDay) {
    dateRegexp = new RegExp("^(\\d{4})[" + delim1 + "](\\d{2})(\\d{2})$");
    } else {
    dateRegexp = new Reg

  • How to  configure  for struts-config.xml

    Hi
    I am having a JSp which is Mapped to anothr action through the registration.The registartion is mapped to action
    <%@ page contentType="text/html;charset=UTF-8" %>
    <%@ page import="org.apache.struts.validator.ValidatorPlugIn" session="true" %>
    <%@ page import="org.apache.struts.Globals" %>
    <%@ taglib uri="/tags/struts-bean" prefix="bean" %>
    <%@ taglib uri="/tags/struts-html" prefix="html" %>
    <%@ taglib uri="/tags/struts-logic" prefix="logic" %>
    <html:html locale="true">
    <head>
    <title><bean:message key="index.title"/></title>
    <html:base/>
    </head>
    <body bgcolor="white">
    <logic:notPresent name="<%= Globals.MESSAGES_KEY %>" >
      <font color="red">
        ERROR:  Application resources not loaded -- check servlet container
        logs for error messages.
      </font>
    </logic:notPresent>
    <%-- :TODO: Need code to do this with moudles
    <logic:notPresent name="<%= ValidatorPlugIn.VALIDATOR_KEY %>" >
      <font color="red">
        ERROR:  Validator resources not loaded -- check Commons Logging
        logs for error messages.
      </font>
    </logic:notPresent>
    --%>
    <h3><bean:message key="registrationForm.title"/>1222AAAAAAAAAAAAA</h3>
    <ul>
      <li><html:link action="Test.jsp">Test212121.jsp</html:link >
       <li><html:link action="/registration"><bean:message key="registrationForm.title"/></html:link></li>
       <%System.out.println("hellooooooooooooo");%>
       <!-- :TODO: Should have a non-JaveScript message-by-field example -->
       <li>
          <html:link action="/jsRegistration"><bean:message key="jsRegistrationForm.title"/></html:link> -
          <bean:message key="jsRegistrationForm.description"/>
       </li>
       <li>
          <html:link action="/multiRegistration"><bean:message key="multiRegistrationForm.title"/></html:link> -
          <bean:message key="multiRegistrationForm.description"/>
       </li>
    </ul>
    <a href="registration.jsp">Registration Test</a>
    <p> </p>
    <h3><bean:message key="typeForm.title"/></h3>
    <ul>
       <li>
          <html:link action="/type"><bean:message key="typeForm.title"/></html:link> -
          <bean:message key="typeForm.description"/>
       </li>
       <li>
          <html:link action="/editJsType"><bean:message key="jsTypeForm.title"/></html:link> -
          <bean:message key="jsTypeForm.description"/>
       </li>
    </ul>
    <p> </p>
    <h3>Change Language | Changez Le Langage</h3>
    <ul>
       <li><html:link action="/locale?language=en">English | Anglais</html:link></li>
       <li>
          <html:link action="/locale?language=fr">French | Francais</html:link> -
          <bean:message key="localeForm.fr"/>
       </li>
       <li>
          <html:link action="/locale?language=fr&country=CA">French Canadian | Francais Canadien</html:link> -
          <bean:message key="localeForm.frCA"/>
       </li>
       <li>
          <html:link action="/locale?language=ja" useLocalEncoding="true">Japanese | Japonais</html:link> -
          <bean:message key="localeForm.ja"/>
       </li>
    </ul>
    <p> </p>
    ==============struts-config.xml=================\<?xml version="1.0" encoding="iso-8859-1"?>
    <!DOCTYPE struts-config PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
    "http://struts.apache.org/dtds/struts-config_1_2.dtd">
    <struts-config>
    <!--============================================== Form Bean Definitions -->
    <form-beans>
    <!-- Registration form bean -->
    <form-bean name="registrationForm" type="validator.RegistrationForm" />
    <!-- Multi-Part Registration form bean -->
    <form-bean name="multiRegistrationForm" type="validator.RegistrationForm" />
    <!-- Type form bean -->
    <form-bean name="typeForm" type="validator.TypeForm" />
    <!-- JavaScript Type form bean -->
    <form-bean name="jsTypeForm" type="validator.TypeForm" />
    </form-beans>
    <!-- ======================================== Global Forward Definitions -->
    <global-forwards>
    <forward name="home" path="/index.jsp" />
    </global-forwards>
    <!-- ========================================= Action Mapping Definitions -->
    <action-mappings>
    <action path="/welcome" forward="/index.jsp" />
    <!-- Registration Action
         -->
    <forward name="registration" path="/registration.do" /> //// ==========>here it is mapped
         <action path="/registration" forward="/registration.jsp" />
         <action path="/registration-submit" type="validator.RegistrationAction" name="registrationForm" scope="request" validate="true" input="input">
    <forward name="input" path="/registration.do" />
    <forward name="success" path="/index.jsp" />
    </action>
         <action path="/jsRegistration" forward="/jsRegistration.jsp" />
    <!-- Multi-Part Registration Action -->
    <action path="/multiRegistration" forward="/multiRegistration1.jsp" />
    <action path="/multiRegistration-submit" type="validator.MultiRegistrationAction" name="multiRegistrationForm" scope="request" validate="false">
    <forward name="success" path="/welcome.do" />
    <forward name="input1" path="/multiRegistration1.jsp" />
    <forward name="input2" path="/multiRegistration2.jsp" />
    </action>
    <!-- Type Action -->
    <action path="/type" forward="/type.jsp" />
    <action path="/type-submit" type="validator.TypeAction" name="typeForm" scope="request" validate="true" input="input">
    <forward name="input" path="/type.do" />
    <forward name="success" path="/welcome.do" />
    </action>
    <!-- JavaScript Type Action -->
    <action path="/editJsType" type="validator.EditTypeAction" scope="request" validate="false">
    <forward name="success" path="/jsType.do" />
    </action>
    <action path="/jsType" forward="/jsType.jsp" />
    <action path="/jsType-submit" type="validator.TypeAction" name="jsTypeForm" scope="request" validate="true" input="input">
    <forward name="input" path="/editJsType-submit.do?typeForm.reset=false" />
    <forward name="success" path="/welcome.do" />
    </action>
    <!-- Locale Action -->
    <action path="/locale" type="validator.LocaleAction" name="localeForm" scope="request">
    <forward name="success" path="/welcome.do" />
    </action>
    </action-mappings>
    <!-- ============================================= Controller Definition -->
    <controller inputForward="true" />
    <!-- ===================================== Message Resources Definitions -->
    <message-resources parameter="validator.MessageResources" />
    <!-- ============================================ Plug Ins Configuration -->
    <!--
    Add multiple validator resource files by setting the pathnames property
    with a comma delimitted list of resource files to load.
    -->
    <plug-in className="validator.ValidatorPlugIn">
    <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validator/validation.xml" />
    <set-property property="stopOnFirstError" value="true" />
    </plug-in>
    </struts-config>
    <html:img page="/struts-power.gif" altKey="index.powered"/>
    </body>
    </html:html>

    Hey,
    U can do it the way u want. Use DispatchAction Class instead of Action Class. Just go through the documentation for this. If u still have problem let me know.
    Thanks
    KM
    Hi,
    I am new to struts and when i am doing my application i find some >>difficulty i.e,
    I have two buttons on a jsp page Save,Delete.when I click on >>save ,saveAction must be called.if we click delete deleteAction to be >>called.
    for this how can I configure in struts-config.xml file. and how it >>knows which button has been clicked.
    Can any one please guid me.
    Thanks

  • Using Multiple Properties Files in Struts Framework

    Hi Everybody!
    I just to know how to use a multiple message-resources files in a Struts Framework.
    I've 2 properties file :
    1. ApplicationResources_A.properties
    2. ApplicationResources_B.propertiesI put the files under WEB-INF/classes dir.
    My configuration in struts-config file something like below:
    <!--  Begin Testing -->
         <message-resources key="A" parameter="ApplicationResources_A" />
         <message-resources key="B" parameter="ApplicationResources_B" />
    <!--  End Testing -->
    </struts-config>
    if my JSP code is like below , this error is thrown:
    org.apache.jasper.JasperException: Cannot find message resources under key A
      <tr>
        <td width="17%">Language A</td>
        <td width="83%"><bean:message bundle="A" key="user.lang.desc"/></td>
      </tr>
      <tr>
        <td width="17%">Language B</td>
        <td width="83%"><bean:message bundle="B"  key="user.lang.desc"/></td>
      </tr>
    but  if I change the  JSP code like below it  work fine:
      <tr>
        <td width="17%">Language A</td>
        <td width="83%"><bean:message key="user.lang.desc"/></td>
      </tr>
      <tr>
        <td width="17%">Language B</td>
        <td width="83%"><bean:message  key="user.lang.desc"/></td>
      </tr>
    In this code , I dont know  which resources file is used.
    So how do I solve this problem. Thanks you.

    I have defined the following:
    struts-config.xml
    <message-resources key="ldap" parameter="com/project/struts/ldap"/>
    Action.java
    In execute method:
    MessageResources messageResources= MessageResources.getMessageResources("com/project/struts/ldap");
    System.out.println("INITIAL_CONTEXT_FACTORY"+messageResources.getMessage("INITIAL_CONTEXT_FACTORY"));
    and it is working, however I have to change "com/project/struts/ldap" value in Action.java file whenever there is any change in name or location of ldap.properties.
    Can I access this properties in such way that I don't have to change parameter path manually in Action.java (modifying in struts-config.xml is okay)? like access through key="ldap" or something.
    Thanks and regards,

  • Plz Solve this Error in    " Client Side Address Validation in Struts "

    Hi,
    i have created struts project and foll code is written as foll :
    plz find out error in code :
    struts-config.xml code
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
    <struts-config>
    <data-sources />
    <form-beans >
    <form-bean name="AddressForm" type="com.projectvalidator.form.AddressForm" />
    </form-beans>
    <global-exceptions />
    <global-forwards />
    <action-mappings >
    <action
    input="/validateaddress.jsp"
    name="AddressForm"
    path="/address"
    scope="request"
    validate="true"
    type="com.projectvalidator.action.AddressAction">
    <forward name="success" path="/success.jsp"/>
    <forward name="failure" path="/validateaddress.jsp"/>
    </action>
    </action-mappings>
    <message-resources parameter="MessageResources" />
    <!-- Validator plugin -->
    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
    <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
    </plug-in>
    </struts-config>
    MessageResources.properties file code
    AddressForm.name=Name      
    AddressForm.address=Address
    AddressForm.email=EmailAddress
    validation.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <form-validation>
    <formset>
    <!-- Address form Validation-->
    <form name="AddressForm">
    <field property="name"
    depends="required" >
    <arg key="AddressForm.name"/>
    </field>
    <field property="address"
    depends="required" >
    <arg key="AddressForm.address"/>
    </field>
    <field property="email"
    depends="required" >
    <arg key="AddressForm.email"/>
    </field>
    </form>
    </formset>
    </form-validation>
    validationaddress.jsp
    <%@ page language="java" pageEncoding="UTF-8"%>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-template" prefix="template" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-nested" prefix="nested" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html:html locale="true">
    <head>
    <html:base />
    <title>validateaddress.jsp</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    </head>
    <body bgcolor=#fdffca>
    <html:form action="/address" method="post" onsubmit="return validateAddressForm(this);">
    <p>
    <html:errors/><p>
    name : <html:text property="name" size="30" maxlength="30" />
    address : <html:text property="address" size="30" maxlength="30" />
    emailaddress : <html:text property="email" size="30" maxlength="30" />
    <html:submit>Submit</html:submit>
    <html:cancel>Cancel</html:cancel>
    <!-- Begin Validator Javascript Function-->
    <html:javascript formName="AddressForm"/>
    <!-- End of Validator Javascript Function-->
              </html:form>
         </body>
    </html:html>
    AddressForm.java
    //Created by MyEclipse Struts
    // XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_3.9.210/xslt/JavaClass.xsl
    package com.projectvalidator.form;
    import org.apache.struts.validator.ValidatorForm;
    * MyEclipse Struts
    * Creation date: 02-23-2006
    * XDoclet definition:
    * @struts:form name="AddressForm"
    public class AddressForm extends ValidatorForm {
         // --------------------------------------------------------- Instance Variables
         /** address property */
         private String address;
         /** emailaddress property */
         private String email;
         /** name property */
         private String name;
         // --------------------------------------------------------- Methods
         * Returns the address.
         * @return String
         public String getAddress() {
              return address;
         * Set the address.
         * @param address The address to set
         public void setAddress(String address) {
              this.address = address;
         * Returns the emailaddress.
         * @return String
         public String getEmail() {
              return email;
         * Set the emailaddress.
         * @param emailaddress The emailaddress to set
         public void setEmail(String email) {
              this.email = email;
         * Returns the name.
         * @return String
         public String getName() {
              return name;
         * Set the name.
         * @param name The name to set
         public void setName(String name) {
              this.name = name;
    AddressAction.java
    //Created by MyEclipse Struts
    // XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_3.9.210/xslt/JavaClass.xsl
    package com.projectvalidator.action;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import com.projectvalidator.form.AddressForm;
    * MyEclipse Struts
    * Creation date: 02-23-2006
    * XDoclet definition:
    * @struts:action path="/address" name="AddressForm" input="/validateaddress.jsp" scope="request" validate="true"
    * @struts:action-forward name="success" path="success.jsp" redirect="true"
    * @struts:action-forward name="failure" path="validateaddress.jsp" redirect="true"
    public class AddressAction extends Action {
         // --------------------------------------------------------- Instance Variables
         // --------------------------------------------------------- Methods
         * Method execute
         * @param mapping
         * @param form
         * @param request
         * @param response
         * @return ActionForward
         public ActionForward execute(
              ActionMapping mapping,
              ActionForm form,
              HttpServletRequest request,
              HttpServletResponse response) {
              AddressForm AddressForm = (AddressForm) form;
              // TODO Auto-generated method stub
              //String forward="";
              //if (AddressForm.getName().equalsIgnoreCase("admin"));
              //return mapping.findForward(forward);
              return null;
    ==========================================
    PLZ REPLY ME ANYONE , I AM NOT GETTING OUTPUT , i am using jboss application server, i am getting a pop-up window as below:
    null is required
    null is required
    null is required
    i hope any one replies me

    Hi,
    i have created struts project and foll code is written as foll :
    plz find out error in code :
    struts-config.xml code
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
    <struts-config>
    <data-sources />
    <form-beans >
    <form-bean name="AddressForm" type="com.projectvalidator.form.AddressForm" />
    </form-beans>
    <global-exceptions />
    <global-forwards />
    <action-mappings >
    <action
    input="/validateaddress.jsp"
    name="AddressForm"
    path="/address"
    scope="request"
    validate="true"
    type="com.projectvalidator.action.AddressAction">
    <forward name="success" path="/success.jsp"/>
    <forward name="failure" path="/validateaddress.jsp"/>
    </action>
    </action-mappings>
    <message-resources parameter="MessageResources" />
    <!-- Validator plugin -->
    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
    <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
    </plug-in>
    </struts-config>
    MessageResources.properties file code
    AddressForm.name=Name      
    AddressForm.address=Address
    AddressForm.email=EmailAddress
    validation.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <form-validation>
    <formset>
    <!-- Address form Validation-->
    <form name="AddressForm">
    <field property="name"
    depends="required" >
    <arg key="AddressForm.name"/>
    </field>
    <field property="address"
    depends="required" >
    <arg key="AddressForm.address"/>
    </field>
    <field property="email"
    depends="required" >
    <arg key="AddressForm.email"/>
    </field>
    </form>
    </formset>
    </form-validation>
    validationaddress.jsp
    <%@ page language="java" pageEncoding="UTF-8"%>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-template" prefix="template" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-nested" prefix="nested" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html:html locale="true">
    <head>
    <html:base />
    <title>validateaddress.jsp</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    </head>
    <body bgcolor=#fdffca>
    <html:form action="/address" method="post" onsubmit="return validateAddressForm(this);">
    <p>
    <html:errors/><p>
    name : <html:text property="name" size="30" maxlength="30" />
    address : <html:text property="address" size="30" maxlength="30" />
    emailaddress : <html:text property="email" size="30" maxlength="30" />
    <html:submit>Submit</html:submit>
    <html:cancel>Cancel</html:cancel>
    <!-- Begin Validator Javascript Function-->
    <html:javascript formName="AddressForm"/>
    <!-- End of Validator Javascript Function-->
              </html:form>
         </body>
    </html:html>
    AddressForm.java
    //Created by MyEclipse Struts
    // XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_3.9.210/xslt/JavaClass.xsl
    package com.projectvalidator.form;
    import org.apache.struts.validator.ValidatorForm;
    * MyEclipse Struts
    * Creation date: 02-23-2006
    * XDoclet definition:
    * @struts:form name="AddressForm"
    public class AddressForm extends ValidatorForm {
         // --------------------------------------------------------- Instance Variables
         /** address property */
         private String address;
         /** emailaddress property */
         private String email;
         /** name property */
         private String name;
         // --------------------------------------------------------- Methods
         * Returns the address.
         * @return String
         public String getAddress() {
              return address;
         * Set the address.
         * @param address The address to set
         public void setAddress(String address) {
              this.address = address;
         * Returns the emailaddress.
         * @return String
         public String getEmail() {
              return email;
         * Set the emailaddress.
         * @param emailaddress The emailaddress to set
         public void setEmail(String email) {
              this.email = email;
         * Returns the name.
         * @return String
         public String getName() {
              return name;
         * Set the name.
         * @param name The name to set
         public void setName(String name) {
              this.name = name;
    AddressAction.java
    //Created by MyEclipse Struts
    // XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_3.9.210/xslt/JavaClass.xsl
    package com.projectvalidator.action;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import com.projectvalidator.form.AddressForm;
    * MyEclipse Struts
    * Creation date: 02-23-2006
    * XDoclet definition:
    * @struts:action path="/address" name="AddressForm" input="/validateaddress.jsp" scope="request" validate="true"
    * @struts:action-forward name="success" path="success.jsp" redirect="true"
    * @struts:action-forward name="failure" path="validateaddress.jsp" redirect="true"
    public class AddressAction extends Action {
         // --------------------------------------------------------- Instance Variables
         // --------------------------------------------------------- Methods
         * Method execute
         * @param mapping
         * @param form
         * @param request
         * @param response
         * @return ActionForward
         public ActionForward execute(
              ActionMapping mapping,
              ActionForm form,
              HttpServletRequest request,
              HttpServletResponse response) {
              AddressForm AddressForm = (AddressForm) form;
              // TODO Auto-generated method stub
              //String forward="";
              //if (AddressForm.getName().equalsIgnoreCase("admin"));
              //return mapping.findForward(forward);
              return null;
    ==========================================
    PLZ REPLY ME ANYONE , I AM NOT GETTING OUTPUT , i am using jboss application server, i am getting a pop-up window as below:
    null is required
    null is required
    null is required
    i hope any one replies me

  • How to add i18n features to a Struts application?

    How to add i18n features to a Struts application?
    txs!

    How to add I18N to Struts application
    operation:
    1) provide your native ascii encoded properties file.
    2) set the correct language priority. (As to IE: Tools - Internet Options - Languages
    3) coding: add correct encoding in your web page, exp. for zh_CN:
    <%@ page contentType="text/html; charset=gb2312" %>
    utility batch file:
    native2ascii -encoding gb2312 MessageResources_zh_CN.txt MessageResources_zh_CN.properties
    copy MessageResources.txt MessageResources_en_US.properties
    note
    Before you run the utility batch file, you should first add %JAVA_HOME%/bin to system %PATH% environment variable.

  • Otherwise functional app. on IWS60sp1 and Struts 1.1 results in error

    An application that was running fine on Tomcat (Struts1.1) has been deployed (successfully!? according to the log) on IWS, but there's an error at runtime:
    [03/Dec/2003:14:32:49] info ( 680): jsp: init
    [03/Dec/2003:14:32:49] failure ( 680): Internal error: Unexpected error condition thrown (unknown exception,no description), stack: java.lang.ExceptionInInitializerError: java.lang.NullPointerException
         at org.apache.struts.util.MessageResources.getMessageResources(MessageResources.java:577)
         at org.apache.struts.taglib.html.BaseTag.<clinit>(BaseTag.java:92)
         at jsps.pages._logon_jsp._jspService(_logon_jsp.java:62)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:248)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.access$6(JspServlet.java:238)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:519)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:588)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.iplanet.server.http.servlet.NSServletRunner.invokeServletService(NSServletRunner.java:919)
         at com.iplanet.server.http.servlet.WebApplication.service(WebApplication.java:1061)
         at com.iplanet.server.http.servlet.NSServletRunner.ServiceWebApp(NSServletRunner.java:981)
    Does it mean this particular instance of IWS is not Struts-enabled?
    Thanks

    following suggestions at:
    http://swforum.sun.com/jive/thread.jspa?forumID=16&threadID=15440
    didn't completely fix the situation:
    [03/Dec/2003:15:22:46] failure ( 680): Internal error: Unexpected error condition thrown (unknown exception,no description), stack: java.lang.NoClassDefFoundError
         at jsps.pages._logon_jsp._jspService(_logon_jsp.java:62)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:248)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.access$6(JspServlet.java:238)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:519)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:588)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.iplanet.server.http.servlet.NSServletRunner.invokeServletService(NSServletRunner.java:919)
         at com.iplanet.server.http.servlet.WebApplication.service(WebApplication.java:1061)
         at com.iplanet.server.http.servlet.NSServletRunner.ServiceWebApp(NSServletRunner.java:981)
    is it some kind of IWS config problem???

  • ErrorStyleClass not working. using displaytag and struts

    struts-config
    <form-bean name="Form" type="org.apache.struts.validator.DynaValidatorForm" dynamic="true">
    <form-property name="hrs" type="java.util.ArrayList"/>
    </form-bean>
    JSP:
    <html:form action="DispatchAction.do" method="post">
    <fmt:setBundle var="appbundle" basename="MessageResources"/>
    <logic:messagesPresent message="true">
    <UL>
    <html:messages id="error" message="true">
    <LI><c:out value="${error}"/></LI>
    </html:messages>
    </UL>
    </logic:messagesPresent>
    <display:table name="sessionScope.Form.hrs" id="rows" requestURI="PrepareAction.do" >
    <display:column titleKey="lbl.hrs">
    <c:set var="ggggg" value="hrs[${rows_rowNum -1}].adHrs"/>
    <c:if test="${rows.adHrs != null}">
    <html:text name="Form" property="<%= pageContext.getAttribute("ggggg").toString() %>" errorStyleClass="errormsg"/>
    </c:if>
    </display:column>
    </display:table>
    </html:form>
    validation.xml
    <formset>
    <form name="Form" >
    <field property="adHrs" indexedListProperty="hrs" depends="integer,validwhen">
    <msg name="integer" key="lbl.notvalid"/>
    <msg name="validwhen" key="lbl.notvalid"/>
    <var>
    <var-name>test</var-name>
    <var-value>(*this* >= 0)</var-value>
    </var>
    </field>
    </form>
    </formset>
    the error messages does display at the top. But the input field is not highlighted.
    The messages are getting displayed only when the messages="true" is given as below
    <logic:messagesPresent message="true">
    <html:messages id="error" message="true">
    not sure why this has to be given either.
    Need help with highlighting too.
    Thanks.

    Hello,
    I am having a similar problem. I would appreciate if somebody can post a solution.
    Thanks,
    Puru

  • Cannot find message resources under key org.apache.struts.action.MESSAGE ?

    Hi All,
    I am getting the following error.. while running a simple application in struts.
    Cannot find message resources under key org.apache.struts.action.MESSAGE ?
    As I have searched in google but could not find the concreate example so please help and give me a proper answer..
    my struts-config.xml file is as .....
    <code>
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE struts-config PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
    "http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">
    <struts-config>
    <!-- ========== Form Bean Definitions ============ -->
    <form-beans>
         <form-bean name="login" type="test.struts.LoginForm" />
    </form-beans>
    <!-- ========== Global Forward Definitions ========= -->
    <global-forwards>
    </global-forwards>
    <!-- ========== Action Mapping Definitions ======== -->
    <action-mappings>
    <action
         path="/login"
         type="test.struts.LoginAction"
         name="login"
         input="/jsp/LoginView.jsp"
         validate="true">
         <forward name="valid" path="/jsp/MainMenu.jsp" />
         <forward name="invalid" path="/jsp/LoginView.jsp" />
         </action>
    </action-mappings>
    <message-resources null="false" parameter="test.struts.MessageResources"/>
    </struts-config>
    </code>
    And my LoginView.jsp file is as:
    <code>
    <!-- LoginView.jsp -->
    <%@ taglib uri="/struts/WEB-INF/struts-html.tld" prefix="html" %>
    <%@ taglib uri="/struts/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/struts/WEB-INF/struts-logic.tld" prefix="struts" %>
    <HTML>
    <HEAD><TITLE><bean:message key="title.login" /></TITLE></HEAD>
    <BODY>
    <bean:message key="heading.login" />
    <html:errors />
    <html:form action="/login">
         <p>
         <bean:message key="label.userId" />:
         <html:text property="userId" size="10" />
         <br>
         <bean:message key="label.passWord" />:
         <html:password property="passWord" size="10" />
         <br><br>
         <html:submit>
              <bean:message key="button.submit" />
         </html:submit>
    </html:form>
    </BODY>
    </HTML>
    </code>
    MessageResources.properties is as :
    <code>
    button.submit=Send for Verification
    error.no.userId=<li>User ID is a required field</li>
    error.no.passWord=<li>Password is a required field</li>
    error.invalid.login=<li>The User ID and/or Password are invalid. Please try again.</li>
    errors.footer=</ul><hr>
    errors.header=<h3><font color="red">Validation Error</font></h3>You must correct the following error(s) before proceeding:<ul>
    label.userId=User ID
    label.passWord=Password
    heading.login=<H2>Enter your user information</H2>
    title.login=Login Screen
    title.mainmenu=Welcome
    heading.mainmenu=<H1>Welcome!</H1>
    label.userType=<H2>You are authorized to use this system as a</H2>
    </code>
    Please reply soon.
    Thanks in advance
    Amitindia

    Hi All,
    I am getting the following error.. while running a simple application in struts.
    Cannot find message resources under key org.apache.struts.action.MESSAGE ?
    As I have searched in google but could not find the concreate example so please help and give me a proper answer.. my struts-config.xml file is as .....
    <?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE struts- 
      config PUBLIC "-//Apache Software Foundation//DTD Struts
    Configuration 1.0//EN" "http://jakarta.apache.org/struts/dtds/struts-
    config_1_0.dtd"> <struts-config> <!-- ========== Form Bean
    Definitions ============ --> <form-beans> <form-bean name="login"
    type="test.struts.LoginForm" /> </form-beans> <!-- ========== Global Forward Definitions ========= --> <global-forwards> </global-
    forwards> <!-- ========== Action Mapping Definitions ======== --> <action-mappings> <action path="/login" type="test.struts.LoginAction" name="login" input="/jsp/LoginView.jsp" validate="true"> <forward name="valid" path="/jsp/MainMenu.jsp" /> <forward name="invalid" path="/jsp/LoginView.jsp" /> </action> </action-mappings> <message-resources null="false" parameter="test.struts.MessageResources"/> </struts-config>
    And my LoginView.jsp file is as:
    <!-- LoginView.jsp --> <%@ taglib uri="/struts/WEB-INF/struts-html.tld" prefix="html" %> <%@ taglib uri="/struts/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/struts/WEB-INF/struts-logic.tld" prefix="struts" %> <HTML> <HEAD><TITLE><bean:message key="title.login" /></TITLE></HEAD> <BODY> <bean:message key="heading.login" /> <html:errors /> <html:form action="/login">
    <bean:message key="label.userId" />: <html:text property="userId" size="10" /> <br> <bean:message key="label.passWord" />: <html:password property="passWord" size="10" /> <br><br> <html:submit> <bean:message key="button.submit" /> </html:submit> </html:form> </BODY> </HTML>
    MessageResources.properties is as :
    button.submit=Send for Verification error.no.userId=<li>User ID is a required field</li> error.no.passWord=<li>Password is a required field</li> error.invalid.login=<li>The User ID and/or Password are invalid. Please try again.</li> errors.footer=</ul><hr> errors.header=<h3><font color="red">Validation Error</font></h3>You must correct the following error(s) before proceeding:<ul> label.userId=User ID label.passWord=Password heading.login=<H2>Enter your user information</H2> title.login=Login Screen title.mainmenu=Welcome heading.mainmenu=<H1>Welcome!</H1> label.userType=<H2>You are authorized to use this system as a</H2>
    Please reply soon. Thanks in advance Amitindia                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Urgent:Struts question

    Hi,
    I am working on a web application using struts framework. I know Struts provides internationalization of messages and labels using MessageResources. I have a requirement that all the error messages (not the fields labels on the form) should come from a table in the database. I know how to do this using a messageresource properties file. Is there any way I can retrieve the error messages from a database table and still be able to provide internationalization. Please help.

    have look at this page:
    http://java.sun.com/docs/books/tutorial/i18n/resbundle/propfile.html
    if they are using a code line like this
    ResourceBundle labels =
    ResourceBundle.getBundle("LabelsBundle", currentLocale);
    in struts you should be able to simply provide
    a class named like the application properties you specify in struts-config.xml implementing the ResourceBoundle interface ... and it should get called for retrievign messages.
    You should be able to find details on the page mentioned above.
    Also it might be a good idea to browse the struts sourcecode for a line like the one above to check if they really do it that way..
    good luck
    Spieler

  • Jakarta Struts in Weblogic?

    Hi All,
              I am trying to get Struts up and running inside of a version 5.1 weblogic
              container. It seems that I am close, because some of the tags work (like
              the link tag). However, any tag that depends on the presence of a resource
              bundle (such as the message tag) fails with the following stack trace:
              Wed Nov 29 10:54:07 PST 2000:<E> <ServletContext-struts-example> Servlet
              failed
              with Exception
              javax.servlet.ServletException: runtime failure in custom tag 'message'
              at jsp_servlet._index._jspService(_index.java:89)
              at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
              at
              weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
              :105)
              at
              weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
              :123)
              at
              weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
              l.java:742)
              at
              weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
              l.java:686)
              at
              weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContext
              Manager.java:247)
              at
              weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:361)
              at
              weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:261)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled
              Code)
              Wed Nov 29 10:54:08 PST 2000:<E> <ServletContext-struts-example> root cause
              of ServletException
              java.lang.NullPointerException:
              at
              weblogic.servlet.jsp.PageContextImpl.getAttribute(PageContextImpl.java:156)
              at
              org.apache.struts.taglib.MessageTag.doStartTag(MessageTag.java:358)
              at jsp_servlet._index._jspService(_index.java:81)
              at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
              at
              weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
              :105)
              at
              weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
              :123)
              at
              weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
              l.java:742)
              at
              weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
              l.java:686)
              at
              weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContext
              Manager.java:247)
              at
              weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:361)
              at
              weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:261)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled
              Code)
              I looked at the source code for MessageTag.java and it fails at the point
              where it is trying to get a "bundle" object (instance of MessageResources)
              out of the PageContext application scope.
              // Acquire the resources object containing our messages
              MessageResources resources = (MessageResources)
              pageContext.getAttribute(bundle, PageContext.APPLICATION_SCOPE);
              If I'm not mistaken, the MessageResources object should contain name/value
              pairs from ApplicationResources.properties. I have that file in its default
              location
              (/WEB-INF/classes/org/apache/struts/example/ApplicationResources.properties)
              . I have not seen any FileNotFoundException's so I think it is finding it
              OK. However, the MessageResources object is either not getting created, or
              is not making it into the application scope. Is there something I need to
              configure in weblogic.properties to insure that the application is
              initializing properly?
              By the way, this is the "struts-example" application that came with the
              struts binary distribution. It works fine under my tomcat installation but
              we use weblogic in production.
              Any suggestions would be helpful.
              Thanks,
              Jeff
              

              So this gets the example working but how do i begin to use it in my application?
              I created a simple web application. - copy index.jsp from example
              Modifed it.
              Created a simple web.xml
              Now when i try to run it i get
              Thu Dec 14 15:25:06 GMT 2000:<E> <WebAppServletContext-mkb> Root cause of Servle
              tException
              javax.servlet.ServletException: runtime failure in custom tag 'message'
              at jsp_servlet._index._jspService(_index.java:133)
              at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
              at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
              pl.java:123)
              at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletCon
              textImpl.java:761)
              at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletCon
              textImpl.java:708)
              at weblogic.servlet.internal.ServletContextManager.invokeServlet(Servlet
              ContextManager.java:252)
              at weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.jav
              a:346)
              at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:246)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:135)
              which seams to be back where i started - unless I'm expected to use the public-html for keeping my site?
              Any help please.
              P.S. does WL6.0 have this problem with struts!
              "Gregory Bush" <[email protected]> wrote:
              >
              >Like everyone else, I had a hell of a time getting the Struts framework to work in Weblogic, but I'm committed to using it and I'm stuck with the Weblogic servlet engine (for now), so I kept with it until I got the demo app working nicely.
              >
              >Don't even bother attempting this unless you are familiar with Weblogic configuration.
              >
              >Here's how it can be done:
              >
              >1) Re-install Weblogic 5.1 in a clean directory and enable JSP support by uncommenting the JSP-related tags in the weblogic.properties file, and change the weblogic.system.listenPort to 80.
              >
              >2) Install service pack 6. Early versions of Weblogic 5.1 are packed with Servlet bugs, and you will get nowhere with them.
              >
              >3) Empty the public_html and serverclasses directories. You might as well clean out clientclasses and servletclasses and any straggling files in myserver while you are at it.
              >
              >4) Un-jar the struts-example.war file into a temporary directory. Weblogic claims to fully support Servlet 2.2 and .war files, etc., but as anyone who has actually tried to use them has found out, that support is so spotty one wonders how they ever get J2EE certification in the first place. WE WILL DEPLOY USING THE weblogic.properties FILE, NOT A web.xml FILE!
              >
              >5) Take the JSPs from the exploded .war file and copy them to your public_html directory.
              >
              >6) Create a WEB-INF directory under your public_html directory and copy action.xml, database.xml and *.tld from the example application's WEB-INF directory into it. DON'T COPY web.xml OR THE DIRECTORIES.
              >
              >7) Copy the org folder from the sample application's WEB-INF/classes directory into your serverclasses directory.
              >
              >8) Un-jar the example app's WEB-INF/lib/struts.jar file into your serverclasses directory and delete the META-INF directory it creates.
              >
              >9) From your Tomcat installation's lib directory, get jaxp.jar and parser.jar and un-jar them into your serverclasses directory, deleting the META-INF directories. If you haven't installed Tomcat, you can get these JARs from Sun.
              >
              >10) Add the following lines to your weblogic.properties file (up to the ****):
              >
              ># Register the DatabaseServlet
              >weblogic.httpd.register.db=org.apache.struts.example.DatabaseServlet
              >weblogic.httpd.initArgs.db=\
              > debug=2
              >
              ># Register our Struts ActionServlet
              >weblogic.httpd.register.*.do=org.apache.struts.action.ActionServlet
              >weblogic.httpd.initArgs.*.do=\
              > application=org.apache.struts.example.ApplicationResources,\
              > config=/WEB-INF/action.xml,\
              > debug=2,\
              > detail=2
              >
              ># Start these servlets when the app server starts
              >weblogic.system.startupClass.StartDatabaseServlet=\
              >     weblogic.servlet.utils.ServletStartup
              >weblogic.system.startupArgs.StartDatabaseServlet=\
              >     servlet=db
              >
              >weblogic.system.startupClass.StartActionServlet=\
              >     weblogic.servlet.utils.ServletStartup
              >weblogic.system.startupArgs.StartActionServlet=\
              >     servlet=*.do
              >
              >****
              >
              >You should now be able to start Weblogic, connect to http://localhost, see the main page and explore the sample application.
              >
              >Note that the database servlet is now exposed to the world as /db, so I wouldn't use that kind of connection pool access in a real application.
              >
              >Also, you wouldn't have to un-jar the library files if you put them on your Weblogic classpath, but that can be painful.
              >
              >Now that you have a clean demo app running, you can integrate your existing application back into the clean installation. It's much easier doing it this way than trying it the other direction.
              >
              

  • Error when running the struts application

    Hi
    i am getting this error when i run my struts application. Do i need to install the xerces parcer and should my local have the ANT. If so how should i confingure ANT
    /JSP/Login.jsp(12,0) Attribute name invalid for tag form according to TLD
    org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
         org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
         org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:236)
         org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:1200)
         org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:821)
         org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1512)
         org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
         org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2393)
         org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2399)
         org.apache.jasper.compiler.Node$Root.accept(Node.java:489)

    Ya I guess everything is right in both the files. Let me paste the contents :-
    WEB.XML
    <!DOCTYPE web-app PUBLIC
         "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
         "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    <display-name>My Inventory</display-name>
    <!-- Standard Action Servlet Configuration -->
    <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
    <param-name>config</param-name>
    <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
    </servlet>
    <!-- Standard Action Servlet Mapping -->
    <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
    </servlet-mapping>
    <!-- The Usual Welcome File List -->
    <welcome-file-list>
    <welcome-file>Login.jsp</welcome-file>
    </welcome-file-list>
    <taglib>
    <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
    <taglib-location>/WEB-INF/struts-html.TLD</taglib-location>
    </taglib>
    </web-app>
    STRUTS-CONFIG.xml
    <!DOCTYPE struts-config PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
    "http://struts.apache.org/dtds/struts-config_1_3.dtd">
    <!--
    Default configuration file for examples application.
    Each module also has its own struts-config under: /WEB-INF/$MODULE/
    @version $Revision: 1.9 $ $Date: 2006-12-03 11:32:52 -0600 (Sun, 03 Dec 2006) $
    -->
    <struts-config>
    <form-beans>
    <form-bean name="Loginform" type = "com.myInventory.Loginform"></form-bean>
    </form-beans>
    <global-exceptions/>
    <global-forwards
    <!-- utilize a custom ActionForward as an example only -->
    </global-forwards>
    <action path="/Login" type="com.myInventory.actions.Loginaction" name="Loginform" input="/Login.jsp">
              <forward name="login_target_success" path="/success.jsp"/>
              <forward name="login_target_failure" path="/login.jsp"/>
              </action>
    </action-mappings>
    <message-resources parameter="MessageResources"/>
    </struts-config>

  • Struts client side validation....

    Hello all,
    I am using struts client and server validation but only the server validation works. I tired looking around the forum but wouldnt find any similar problem.
    I am getting value from the previous action class and i am able to successfully retrieve and display the value. I inserted the value in a object and pass over to my jsp. When i try inserting the validation, the server side works fine but i get nth on the client side. I viewed the source code of my jsp and the JAVASCRIPT is successfully inserted but no pop up when i leave the fill blank. Please advise mi..
    1)update.jsp will retrieve data from a object and display them in text box
    struts config file**
    <form-bean name="UpdateMarks" type="fypms.form.UpdateMarksForm" />
    <action name="UpdateMarks"
    path="/updateMarks"
    type="fypms.action.UpdateStudentMarks"
    scope="request"
    validate="true"
    input="/pages/UpdateStudentMarks.jsp" >
    <forward name="successfulUpdate" path="/pages/successfulUpdate.jsp" />
    <forward name="wrongHelloId" path="/pages/wrongHelloWorld.jsp" />
    </action>
    <message-resources parameter="MessageResources"/>
    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
    <set-property
    property="pathnames"
    value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
    </plug-in>
    validation.xml**
    <!-- javascript validation for Update Presentation marks page -->
    <form name="UpdateMarks">
    <field property="first_Present"
    depends="creditCard">
    <arg key="prompt.firstPresent" />
    </field>
    <field property="final_Present"
    depends="creditCard">
    <arg key="prompt.finalPresent" />
    </field>
    </form>
    updatemarksform.java**
    private String adminNo[];
         private String first_Present[];
         private String final_Present[];
         private String batchNumber;
         //private String batchNumber;
         public ActionErrors validate( ActionMapping mapping, HttpServletRequest request)
              ActionErrors errors = new ActionErrors();
              List testing = new ArrayList();
              System.out.println("out");
              for(int x=0; x < first_Present.length;x++)
                   System.out.println("firsT" + first_Present[x].length());
                   if (first_Present[x].length()<1)
                        System.out.println("a");
                        //userId not entered
                        errors.add("marks.firstPresentation", new ActionMessage("marks.firstPresentation"));
                   if (final_Present[x].length()<1)
                        //password not entered
                        errors.add("marks.finalPresentation", new ActionMessage("marks.finalPresentation"));
              request.setAttribute("StudentList", testing);
              return errors;
    update.jsp**
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@ page import="fypms.model.*" %>
    <link href="/FYPMS/css/style.css" rel="stylesheet" type="text/css">
    <!--Can contains: JSP -->
    <html:html locale="true">
    <html:form action="/updateMarks" method="post" onsubmit="return validateUpdateMarks(this);">
    <html:errors/>
         <table>
    <tr>
    <td>Name</td>
    <td>Admin Number</td>
    <td>First Presentation</td>
    <td>Final Presentation</td>
    </tr>
    <logic:iterate id="myCollectionElement" name="StudentList">
    <tr>
    <td> <bean:write name="myCollectionElement" property="name"/><html:hidden name="hiddenBatch" property="batchNumber"/></td>
    <td> <bean:write name="myCollectionElement" property="adminNo"/><html:hidden name="myCollectionElement" property="adminNo"/></td>
    <td> <html:text name="myCollectionElement" property="first_Present" /></td>
    <td> <html:text name="myCollectionElement" property="final_Present" /> </td>
    </tr>
    </logic:iterate>
    >
    <tr><td colspan="4"><html:submit value="enter"/></td></tr>
         </table>
    <!-- Begin Validator Javascript Function-->
    <html:javascript formName="UpdateMarks" staticJavascript="true" />
    <!-- End of Validator Javascript Function-->
    </html:form>
    </html:html>
    thank in advance

    # -- validation text(display text) for login page --
    valid.title=Simple Validation Test Form
    prompt.username=Username
    prompt.password=Password
    prompt.phone=Phone Number
    prompt.email=E-Mail Address
    prompt.url=URL (Website Address)
    login.userid = Username is required
    login.password = Password is required
    #-- validation text(display text) for Update presentation marks page --
    prompt.firstPresent=first_Present
    prompt.finalPresent=final_Present
    marks.firstPresentation=First Presentation marks is required
    marks.finalPresentation=Final Presentation marks is required
    thx for ur help ^^
    Message was edited by:
    fatmond

  • JSF versus Struts

    Hi, I'm researching JSF and Struts and they look identical. Seems like the developers of JSF just took Struts and changed the wording. What I mean is:
    struts-config.xml became faces-config.xml
    ActionMappings and Actions became NavigationCases and NavigationRules
    FormBeans became ManagedBeans
    MessageResources became MessageBundle
    ActionServlet became FacesServlet (in web.xml)
    Both have validators and converters.
    So am i missing something?
    Also, are there any performance benchmarks that JSF/Struts add to response times?
    Thanks,
    Mike

    I tried out JSF on some small projects and it worked out OK. However, when I tried using JSF on a major project, I got burned. I ended up converting all my JSF work to Struts.
    Before I say what I didn't like about JSF, let me say what I do like. I like how easy it was to associate a button or a link with a method. I like how easy it is to validate input. I liked how easy it is to show or hide components based on boolean expressions. When it comes to these things, I was able to develop code a bit faster with JSF than with Struts.
    However, the negatives were so great that I eventually abandon JSF...
    (1) If you have a graphic artist that creates prototypes using static HTML, converting those prototypes to actual working pages is MUCH easier with Struts tags than with JSF tags. The problem with JSF tags is that you cannot always mix JSF with standard HTML. This is especially true if you are using Tiles. You may end up having to completely rewrite the static HTML tags to their JSF equivalent. This is simply more trouble than it is worth. (There are JSF tag libraries available that act like standard HTML tags, but I found the tags to be buggy and the code simply very cluttered.)
    (2) Creating tables much more complicated that a textbook example can end up being more trouble than it's worth. For example, if you want to create a table where some rows are sub-headers (rows that span all columns and contain a sub-title), then you will end up having to create a custom renderer and a custom tag library. There is a learning curve involved with this. (Even if you are an expert in writing these, you still have extra code that needs to be written.) With Struts, the same thing can be accomplished with some simple logic tags.
    (3) Sometimes, all I really wanted was to iterate through a list of values. JSF does not come with a simple iterate tag. You can loop through your data with a JSTL tag or you can use a datatable or you can create your own tags, but that is extra work. Even if you choose to do any of these, you still cannot reliably mix standard HTML tags with JSF tags.
    (4) Everything in JSF is submitted as a POST. Sometimes, I really needed to use a GET. You can use GETs in JSF, but I found using them to be less than straightforward.
    My advise: If you are building a web app, use a framework that plays well with HTML. (Ultimately, your web app is generating HTML anyway.) If you are building a stand-alone app, use Swing or some language other than Java. If you need your code to run as both, then JSF might be a solution.
    I really wanted JSF to work for me, but I ended up being disappointed.

Maybe you are looking for