I have a bean something like:
public class NormalTestQuestionBean implements Serializable {
private static final long serialVersionUID = -8455246466385706192L;
private int qId;
private
String qText;
public int getQId() {
return qId;
}
public void setQId(int id) {
qId = id;
}
public String getQText() {
return qText;
}
public void setQText(String text) {
qText = text;
}
}
and a
servlet something like:
public class ControlServlet extends HttpServlet {
private static final long serialVersionUID = 1797971647102217363L;
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
NormalTestQuestionBean[] qList = NormalTestBroker.loadNormalTest();
request.getSession().setAttribute("qList", qList);
getServletContext().getRequestDispatcher("NormalTest.jsp").forward(request, response);
} catch (DBException e) {
request.setAttribute("message", "Database error");
getServletContext().getRequestDispatcher("message.jsp").forward(request, response);
}
}
}
and finally my
JSP, like:
<%@ page language="java" contentType="text/html; charset=BIG5" pageEncoding="BIG5"%>
<%@ page isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=BIG5">
<title>Normal
Test</title>
</head>
<body>
<form action="ControlServlet" action="post">
<table>
<c:forEach var="question" items="${qList}" varStatus="status">
<tr>
<td align="right"><c:out value="${status.count}"/></td>
<td><c:out value="${question.qText}"/></td>
</tr>
</c:forEach>
</table>
<input type="submit" value="Done" align="middle">
</form>
</body>
</html>
This JSP give this error:
javax.servlet.ServletException: Unable to find a value for "qText" in object of class "elvis.bean.NormalTestQuestionBean" using operator "."
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:867)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:800)
org.apache.jsp.NormalTest_jsp._jspService(NormalTest_jsp.java:65)
What is I doing wrong? Please help!
[ January 21, 2007: Message edited by: Bear Bibeault ]