• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSLT printing c:out value

 
sun ram
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to print the hastable name value, but its not working.
Here is the code, I want to print name key value.
===========
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.util.*" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<html>
<head>
<title>c:set test</title>
</head>
<body>
C:Set Test
<br>
<jsp:useBean id="n" class="java.util.Hashtable" />
<c:set value="name" target="${n}" property="Hello World"/>
name values is:
<c ut value="${n.name}"/>

</body>
</html>
============
I except the out Hello World, But its not printing.
Any help?
SR
 
Sam chen
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try the following:
<jsp:useBean id="n" class="java.util.Hashtable" />
<c:set value="Hello World" target="${n}" property="name" />
name value is:
<c ut value="${n.name}" />
I got the Hello World.
 
Mike Wang
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. uri for core is uri="http://java.sun.com/jsp/jstl/core" not
uri="http://java.sun.com/jstl/core" as suggested in JSTL spec.
2. with

you put a string ("name") with key ("Hello World") into the Map ${n}
if you want to print the value with key "Hello World"
you need to use

not

because the there is not key ("name") availible in the map ${n}

btw: is not working

Originally posted by sun ram:
Hi,
I want to print the hastable name value, but its not working.
Here is the code, I want to print name key value.
===========
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.util.*" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<html>
<head>
<title>c:set test</title>
</head>
<body>
C:Set Test
<br>
<jsp:useBean id="n" class="java.util.Hashtable" />
<c:set value="name" target="${n}" property="Hello World"/>
name values is:
<c ut value="${n.name}"/>

</body>
</html>
============
I except the out Hello World, But its not printing.
Any help?
SR
 
sun ram
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, It worked.
-SR
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic