• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HFS page 509

 
Sami Sayeed
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In the HFS page 509 it is mentioned that the "At the point where the tag is invoked,
"message" is NOT a scoped Attribute !
If you took this expression out of the tag, it woudl return null.

I have a program as follows
package com.test;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.SimpleTagSupport;
import java.io.*;

public class SimpleTagHandler3 extends SimpleTagSupport
{

public void doTag() throws JspException, IOException
{
getJspContext().setAttribute("name","SAMI");
getJspBody().invoke(null);
}

}

the jsp is as follows
<%@taglib uri="test3" prefix="sami" %>
<% int i=0;%>
<sami:test>
${name}
</sami:test>
<br>
\${name}=${name}// name has the value after the tag as well???

the tld is as follows
<?xml version="1.0"?>
<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.0">
<tlibversion>1.2</tlibversion>
<uri>test3</uri>
<tag>
<name>test</name>
<tag-class>com.test.SimpleTagHandler3</tag-class>
<body-content>scriptless</body-content>
</tag></taglib>
 
Dale Seng
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sami Sayeed:
Hi,

In the HFS page 509 it is mentioned that the "At the point where the tag is invoked,
"message" is NOT a scoped Attribute !
If you took this expression out of the tag, it woudl return null.

\${name}=${name}// name has the value after the tag as well???

I think the point the authors were trying to make is that "message" is not scoped BEFORE entering into the tag. So here you are, putting a variable in your jsp that you KNOW is not there!! The book never says what happens after the tag, but there's no magic there... it's a scoped attribute when we call invoke on the body, and NOBODY said "all scoped attributes used in a tag are removed when the tag ends..." .

Maybe it should have said "If you took this expression out of the tag and put it before the tag, it would return null."

--Dale--
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic