Should I be able to create a variable using <c:set> and then use it to set
the value of an attribute in my own custom tag?
When I try and use "${myVar}" to pass the value to my custom tag, what
receive is the literal "${myVar}". In otherwords it doesn't evaluate the
expression. I've tested under Tomcat 4.0.6, 4.1.17 and 4.1.18.
I've created the smallest possible test case and am including all the files.
Thanks,
Randy
=== JSP PAGE ===
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jstl/xml" %>
<%@ taglib uri="portaltags" prefix="xe" %>
<html><body>
<c:set var="myVar" scope="page" value="1"/>
<p><xe:MsgType messageType="${myVar}"/>
</body></html>
=== The taglib.tld ===
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library
1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.2</jspversion>
<shortname>xe</shortname>
<uri>http://www.test.com/portaltags.html</uri>
<info>XePortal</info>
<tag>
<name>MsgType</name>
<tagclass>com.test.XeTestTag</tagclass>
<info>Gets message types</info>
<attribute>
<name>messageType</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
=== The web.xml ===
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Portal</display-name>
<description>
Portal
</description>
<taglib>
<taglib-uri>portaltags</taglib-uri>
<taglib-location>/WEB-INF/taglib.tld</taglib-location>
</taglib>
</web-app>
=== The Java file ===
package com.test;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.tagext.TagSupport;
public class XeTestTag extends TagSupport
{
private String messageType = "0";
/**
* Constructor for XeTestTag.
*/
public XeTestTag()
{
super();
}
/**
* Sets the messageType.
* @param messageType The messageType to set
*/
public void setMessageType(String messageType)
{
this.messageType = messageType;
System.out.println("MessageType: " + messageType);
}
/**
* Output the requested function.
* @return int
*/
public int doEndTag() throws JspTagException
{
try
{
pageContext.getOut().write(messageType);
}
catch (java.io.IOException e)
{
throw new JspTagException("IO Error: " +
e.getMessage());
}
return EVAL_PAGE;
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>