How to Solve: tag nesting error? in Struts project.
843835Jan 2 2003 — edited Jul 24 2005Hello, EveryBody:
I am working for a Struts system in testing a program of look-up user password via user-inputs with birthdate, postal code, userid. I have writen three program, lookup.jsp, LookupForm.java, LookupAction.java. When I get the lookup.jsp run, the web browser displays "HTTP 500". Please find the attached message for error message, lookup.jsp and Lookupform.java. Thanks a lot.
--------------------------------------------------------------------
HTTP Status 500 -
type: Exception report
message: description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.compiler.ParseException: End of content reached while more parsing required: tag nesting error?
at org.apache.jasper.compiler.JspReader.popFile(JspReader.java:293)
at org.apache.jasper.compiler.JspReader.hasMoreInput
..........(Omit)
lookup.jsp:
<%@ page language="java" import="com.tfu.struts.common.Constants" %>
<%@ taglib uri="/WEB-INF/app.tld" prefix="app" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html:html locale="true">
<head>
<title><bean:message key="lookup.title"/></title>
<html:base/>
</head>
<body bgcolor="#FFFFFF" background="images/FREE-bg.gif">
<%@ include file="header1.html" %>
<html:errors/>
<%
String selectedMonthValue = (String)request.getAttribute(Constants.SELECTED_MONTH_KEY);
log("selectedMonthValue = " + selectedMonthValue);
String selectedCountryValue = (String)request.getAttribute(Constants.SELECTED_COUNTRY_KEY);
log("selectedCountryValue = " + selectedCountryValue);
%>
<html:form action="/lookup">
<html:hidden property="action">
<table>
<tr><td><bean:message key="prompt.lookup.signin"/></td></tr>
<tr><td><bean:message key="prompt.lookup.notes1"/>
<bean:message key="prompt.lookup.notes2"/></td>
</tr>
<tr><td><bean:message key="prompt.lookup.step1"/>
<bean:message key="prompt.lookup.step11"/></td>
</tr>
<tr>
<td><bean:message key="prompt.birthdate"/></td>
<td>
<html:select property="birthmonth" size="1">
<html:options collection="<%= Constants.MONTH_ARRAY_KEY %>"
property="value"
labelProperty="label"/>
</html:select>
<html:text property="birthday" size="2"/>
<bean:message key="prompt.birthdate.comma"/>
<html:text property="birthyear" size="4"/>
<bean:message key="prompt.birthdate.tail"/>
</td></tr>
<tr>
<td><bean:message key="prompt.postcode"/></td>
<td><html:text property="postcode" size="10" maxlength="16"/></td>
<td><bean:message key="prompt.country"/></td>
<td>
<html:select property="country" size="1">
<html:options collection="<%= Constants.COUNTRY_ARRAY_KEY %>"
property="value" labelProperty="label"/>
</html:select>
</td>
</tr>
<tr>
<td>
<bean:message key="prompt.lookup.step2"/>
<bean:message key="prompt.lookup.step21"/>
</td>
</tr>
<tr><td><html:text property="userid" size="16" maxlength="16"/></td></tr>
<tr><td><html:submit property="submit" value="Get Password"/></td></tr>
</table>
</html:form>
<bean:write name="LookupForm" property="password"/>
<br>
<br>
<br>
<br>
<br>
<br>
<%@ include file="footer0.html" %>
</body>
</html:html>
</html>
LookupForm.java
/*
* $Header: /com/tfu/struts/lookup/LookupForm.java
* $Revision: 1.0 $
* $Date: 2002/12/31 $
*
* writen by Jianming Ke 2002.12.31
*/
package com.tfu.struts.lookup;
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;
import com.tfu.struts.common.Constants;
/**
* Form bean for the user password retrieve.
*/
public final class LookupForm extends ActionForm {
// --------------------------------------------------- Instance Variables
private String birthmonth = null;
private String birthday = null;
private String birthyear = null;
private String postcode = null;
private String country = null;
private String userid = null;
private String password = null;
// ----------------------------------------------------------- Properties
public String getBirthmonth() {
return (this.birthmonth);
}
public void setBirthmonth(String birthmonth) {
this.birthmonth = birthmonth;
}
public String getBirthday() {
return (this.birthday);
}
public void setBirthday(String birthday) {
this.birthday = birthday;
}
public String getBirthyear() {
return (this.birthyear);
}
public void setBirthyear(String birthyear) {
this.birthyear = birthyear;
}
public String getPostcode() {
return (this.postcode);
}
public void setPostcode(String postcode) {
this.postcode = postcode;
}
public String getCountry() {
return (this.country);
}
public void setCountry(String country) {
this.country = country;
}
public String getUserid() {
return (this.userid);
}
public void setUserid(String userid) {
this.userid = userid;
}
public String getPassword() {
return (this.password);
}
public void setPassword(String password) {
this.password = password;
}
// --------------------------------------------------------- Public Methods
/**
* Validate the properties that have been set from this HTTP request,
* and return an <code>ActionErrors</code> object that encapsulates any
* validation errors that have been found. If no errors are found, return
* <code>null</code> or an <code>ActionErrors</code> object with no
* recorded error messages.
*
* @param mapping The mapping used to select this instance
* @param request The servlet request we are processing
*/
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if ((postcode == null) || (postcode.length() < 1))
errors.add("postcode", new ActionError("error.postcode.required"));
if ((userid == null) || (userid.length() < 1))
errors.add("userid", new ActionError("error.userId.required"));
return errors;
}
}
I edited the struts-config.xml with two segments:
<!-- ========== Form Bean Definitions ================== -->
<form-beans>
<!-- Logon form bean -->
<form-bean name="logonForm"
type="com.tfu.struts.logon.LogonForm">
</form-bean>
<!-- Lookup form bean -->
<form-bean name="lookupForm"
type="com.tfu.struts.lookup.LookupForm">
</form-bean>
<!-- ========== Action Mapping Definitions ================= -->
<action-mappings>
<!-- Lookup a user password -->
<action path="/lookup"
type="com.tfu.struts.lookup.LookupAction"
name="lookupForm"
scope="request"
input="/lookup.jsp">
<forward name="lookpass" path="/logon.jsp"/>
</action>