O
ola.mattsson
Hi, I've just started working with taglibraries in jsp pages but I
can't get it to work...
I have a very simple "helloWorld.jsp" page where I try to list all
headers in the request.
Here is the complete jsp page code:
<%@ page language="java" import="java.util.*"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%
Enumeration headerNames = request.getHeaderNames();
Map<String, String> headers = new HashMap<String, String>();
while(headerNames != null && headerNames.hasMoreElements()){
String s = (String)headerNames.nextElement();
headers.put(s, (String)request.getHeader(s));
}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'helloWorld.jsp' starting page</title>
</head>
<body>
This is my JSP page. <br>
Welcome to the world of JSP.<br>
<c:forEach var="entry" items="${headers}">
${entry.key } = ${entry.value }
</c:forEach>
</body>
</html>
When I access this page in a browser I get the Internal Server error
message:
"org.apache.jasper.JasperException: /helloWorld.jsp(20,4) According to
TLD or attribute directive in tag file, attribute items does not accept
any expressions"
As I understand it I can't use the EL expression ${headers} to set the
value for the items attribute in the <c:forEach ></c:forEach> tag.
But in every "tutorial" I've seen (not that I've found any *good*
tutorial) on the subject, you use an EL expression to set the items
attribute, so what is wrong here?
I'm running this on a Tomcat 5.5.20 and the webapp is deployed by the
MyEclipse J2EE development plugin for Eclipse.
So, can you either tell me about a good taglibs tutorial or if you know
what the cause for this problem is (besides the problem between the
chair and the keyboard of course) and how to solve it?
can't get it to work...
I have a very simple "helloWorld.jsp" page where I try to list all
headers in the request.
Here is the complete jsp page code:
<%@ page language="java" import="java.util.*"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%
Enumeration headerNames = request.getHeaderNames();
Map<String, String> headers = new HashMap<String, String>();
while(headerNames != null && headerNames.hasMoreElements()){
String s = (String)headerNames.nextElement();
headers.put(s, (String)request.getHeader(s));
}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'helloWorld.jsp' starting page</title>
</head>
<body>
This is my JSP page. <br>
Welcome to the world of JSP.<br>
<c:forEach var="entry" items="${headers}">
${entry.key } = ${entry.value }
</c:forEach>
</body>
</html>
When I access this page in a browser I get the Internal Server error
message:
"org.apache.jasper.JasperException: /helloWorld.jsp(20,4) According to
TLD or attribute directive in tag file, attribute items does not accept
any expressions"
As I understand it I can't use the EL expression ${headers} to set the
value for the items attribute in the <c:forEach ></c:forEach> tag.
But in every "tutorial" I've seen (not that I've found any *good*
tutorial) on the subject, you use an EL expression to set the items
attribute, so what is wrong here?
I'm running this on a Tomcat 5.5.20 and the webapp is deployed by the
MyEclipse J2EE development plugin for Eclipse.
So, can you either tell me about a good taglibs tutorial or if you know
what the cause for this problem is (besides the problem between the
chair and the keyboard of course) and how to solve it?