jstl problem
Hi,
I have a problem in showing a getparameter with name "data".
Now, I wrote my program codes:
file name : ShowContactsServlet.java
import java.io.*;
import java.util.ArrayList;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.jasper.tagplugins.jstl.core.ForEach;
import business.ContactBO;
import model.contact;
public class ShowContactsServlet extends HttpServlet {
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
ArrayList cList = ContactBO.boInstance.findAll();
contact[] data = new contact[cList.size()];
for (int i = 0; i < cList.size(); i++) {
data[i] = (contact)cList.get(i);
}
req.setAttribute("data", data);
req.getRequestDispatcher("showcontacts.jsp").forwa rd(req, res);
}
}
File name: showcontacts.jsp
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=windows-1256"
pageEncoding="windows-1256"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256">
<title>showcontacts</title>
</head>
<body>
<h1>Addressbook-Show Contacts</h1>
<c:forEach items="${data}" var="d" >
<c:out value="${d.fName}" />
</c:forEach>
......
</body>
</html>
But in runtime I face to this exception:
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.JasperException: Exception in JSP: /showcontacts.jsp:17
14:
15:
16: <c:forEach items="${data}" var="d" >
17: <c:out value="${d.fName}" />
18: </c:forEach>
19:
20: <br/>
or when I use the code "${d.getFName()}" instead of code "${d.fName}" I get the exception below :
org.apache.jasper.JasperException: /showcontacts.jsp(17,1) The function getFName must be used with a prefix when a default namespace is not specified
Now if anybody could help me.
if it's possible for you a bit sooner give the answer of my problem.
thanks every body
bye
|