Hi,
I have some problem using Struts with JSP.
I got an error here:
org.apache.jasper.JasperException: An exception occurred processing
JSP page /html/portlet/contact_us_portlet/input.jsp at line 35
32:
33: <logic:messagesPresent>
34: <span class="es-error">
35: <bean:message key="error.userinput.invalid"/>
36: </span>
37: </logic:messagesPresent>
38:
I am writing a customer Contact form.
The Action form is written as below:
public class ContactUsForm extends ActionForm {
private String comment="";
private String name="";
private String phone="";
private String emailaddr="";
private String userinput="";
public String getName() { return this.name; };
public String getEmailaddr() { return this.emailaddr; };
public String getComment() { return this.comment; };
public String getPhone() { return this.phone; };
public String getUserinput() { return this.userinput; };
public void setUserinput() { this.userinput = ""; };
public void setName(String name) { this.name = name; };
public void setEmailaddr(String emailaddr) { this.emailaddr = emailaddr; };
public void setComment(String comment) { this.comment = comment; };
public void setPhone(String phone) { this.phone = phone; };
public void reset(ActionMapping mapping, HttpServletRequest req) {
this.comment="";
this.name="";
this.phone="";
this.emailaddr="";
}
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest req) {
ActionErrors errors = new ActionErrors();
if ((this.comment == null) || (this.comment.length() < 1)
|| this.name == null || this.name.length() < 1
|| this.phone == null || this.phone.length() < 1
|| this.emailaddr == null || this.emailaddr.length() < 1)
{
errors.add("userinput", new ActionMessage("error.userinput.invalid"));
}
return errors;
}
}
JSP part:
<%@ include file="/html/portlet/contact_us_portlet/init.jsp" %>
<bean:define id="name" name="ContactUsForm" property="name"
type="java.lang.String" />
<bean:define id="emailaddr" name="ContactUsForm" property="emailaddr"
type="java.lang.String" />
<bean:define id="phone" name="ContactUsForm" property="phone"
type="java.lang.String" />
<bean:define id="comment" name="ContactUsForm" property="comment"
type="java.lang.String" />
<bean:define id="userinput" name="ContactUsForm" property="userinput"
type="java.lang.String" />
<logic:messagesPresent>
<span class="es-error">
<bean:message key="error.userinput.invalid"/>
</span>
</logic:messagesPresent>
<p align=right>
<a href="<portlet:renderURL portletMode="help" />">Help</a>
</p>
<p align=center>
<html:form action="/contact_us_portlet/input" method="post"
focus="cu_firstname">
<table class="stats">
<tr>
<td><bean:message key="form.title.name"/></td>
<td><input name="cu_name" size="20"/></td>
</tr>
<tr>
<td><bean:message key="form.title.email"/></td>
<td><input name="cu_email" size="30"/></td>
</tr>
<tr>
<td><bean:message key="form.title.phone"/></td>
<td><input name="cu_phone" size="30"/></td>
</tr>
<tr>
<td><bean:message key="form.title.input"/></td>
<td>
<html:textarea name="ContactUsForm" property="comment" rows="12"
cols="40" />
</td>
</tr>
</table>
</p>
<p align=center>
<html:submit><bean:message key="button.submit"/></html:submit>
</html:form>
</p>
Is there anything wrong with my coding in the Action form and the JSP?
What have I missing?
Your help is very much appreciated.
Thanks
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]