Thanks. I currently have a workaround using the nested JSP attribute tag.
<cs:subscriptionInfo nameVar="subName" descriptionVar="subDesc">
<jsp:attribute name="targetID">
<c:out value="${subID}"/>
</jsp:attribute>
</cs:subscriptionInfo>
This appears to work. *shrug*
I keep thinking that there is something Im missing in my tag implementation.
-- Robert
Keshav Shetty wrote:
Although I couldn't find the actual reason to your problem, But I have a workaround.
Instead of EL use direct JSP expression like <%=subID%> in the code i.e
<cs:subscriptionInfo targetID="<%=subID%>" nameVar="subName" descriptionVar="subDesc"/>
Please take care that subID variable present and initialised in your JSP. I will analyze further reagrding your problem during my free time later.
Thanks & regards Keshav Shetty
Robert Simmons Jr. wrote:
That just made my EL expressions in my JSTL tags explode ... if I put in that directive then I get the following result:
org.apache.jasper.JasperException: /JSPs/AdminSubscriptions.jsp(22,1) According to TLD or attribute directive in tag file, attribute test does not accept any expressions
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:146)
org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:955)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:710)
org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1441)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Validator.validate(Validator.java:1489)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:157)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:296)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
The relevant line is:
<c:if test="${!empty param['edit']}"> </c:if>
The entire JSP page looks like the following:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="cs" uri="http://www.jambit.com/taglibs/bmw/candy/CandiedServices" %>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="eng"> <head> <title>Administer Candied Services Subscriptions</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> </head>
<body>
<!-- Forward to the subscriber Editing page--> <c:if test="${!empty param['edit']}"> </c:if>
<!-- Destroy a subscriber. -->
<c:if test="${!empty param['destroy']}">
<cs:destroySubscription>
<jsp:attribute name="targetID"><c:out value="${param['selectedID']}"/></jsp:attribute> </cs:destroySubscription>
<hr/>
<b>Destroyed Subscription:</b> <br/>
ID = <c:out value="${param['selectedID']}"/><br/>
<hr/>
</c:if>
<!--Create a new Subscription. -->
<c:if test="${!empty param['create']}">
<c:set var="subName" value="${param['newsub.name']}"/>
<c:set var="subDesc" value="${param['newsub.description']}"/>
<cs:createSubscription>
<jsp:attribute name="var">neoSubID</jsp:attribute>
<jsp:attribute name="name"><c:out value="${subName}"/></jsp:attribute>
<jsp:attribute name="description"><c:out value="${subDesc}"/></jsp:attribute>
</cs:createSubscription>
<hr/>
<b>Created Subscription:</b> <br/>
ID = <c:out value="${neoSubID}"/><br/>
Name = <c:out value="${subName}"/><br/>
Description = <c:out value="${subDesc}"/><br/>
<hr/>
</c:if>
<center>
<h1>Administer Candied Services Subscriptions </h1>
</center>
<hr/>
<cs:listSubscriptions var="subs" username="admin" password="minda"/>
<form name="edit.<c:out value="${subID}"/>"
action="AdminSubscriptions.jsp" method="post">
<table border=1 cellspacing=0 cellpadding=2 width="90%" >
<tr>
<th></th>
<th align="center">ID</th>
<th align="center">Name</th>
<th align="center">Description</th>
</tr>
<c:forEach var="subID" items="${subs}">
<cs:subscriptionInfo targetID="${subID}" nameVar="subName" descriptionVar="subDesc"/>
<tr>
<td width="1" height="1" valign="middle">
<input type="radio" name="selectedID"
value="<c:out value="${subID}"/>"/>
</td>
<td width="*"><c:out value="${subID}"/></td>
<td width="*"><c:out value="${subName}"/></td>
<td width="*"><c:out value="${subDesc}"/></td>
</tr>
</c:forEach>
</table>
<input type="submit" name="edit" value="Edit"/>
<input type="submit" name="destroy" value="destroy"/>
</form>
<h3>Create a New Subscription</h3>
<form name="create" action="AdminSubscriptions.jsp" method="post">
<input type="text" name="newsub.name" maxlength="15" size="15">
<input type="text" name="newsub.description" maxlength="256" size="40">
<input type="submit" name="create" value="Create"><br/>
</form>
</body>
</html>
-- Robert
Keshav Shetty wrote:
I concluded that your EL are not evaluated. I think you have to use <%@ page isELIgnored="false"%> in your jsp.
I hope this will solve your problem. You can also refer to http://forum.java.sun.com/thread.jspa?threadID=573209&messageID=2848229
Let me know the result.
Best regards Keshav Shetty
Robert Simmons Jr. wrote:
Greetings;
I have a tag that I created to allow integration with my back end. I am using the Jakarta astandard taglibs extensively in the application but I am a bit of a taglib newbie and I have a problem. Namely when I use EL expressions in my tag attributes, they get passed verbatim to the tag and never evaluated.
For example, if I use:
<cs:subscriptionInfo targetID="${subID}" nameVar="subName" descriptionVar="subDesc"/>
Then targetID gets passed the literal string ${subID} which causes the page to
explode since targetID needs to be a long. The TLD for this tag is indicated below:
<tag>
<description>
Fetches information on a particular subscription.
</description>
<name>subscriptionInfo</name>
<tag-class>com.bmw.candy.candiedServices.tags.TagSubscriptionInfo</tag-class>
<body-content>empty</body-content>
<attribute>
<description>
ID of the subscription for which to obtain info.
</description>
<name>targetID</name>
<type>java.lang.Long</type>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>
The variable in which to store the subscription name.
</description>
<name>nameVar</name>
<type>java.lang.String</type>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>
The variable in which to store the subscription description.
</description>
<name>descriptionVar</name>
<type>java.lang.String</type>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>
The variable in which to store the subscription items.
</description>
<name>itemsVar</name>
<type>java.lang.String</type>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>
The variable in which to store the subscription last sequence number.
</description>
<name>sequenceNumVar</name>
<type>java.lang.String</type>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
You can see that I set rtexprvalue to true in all cases yet there is no resolution hapening. The implementation of this tag is shown here:
import java.io.IOException;
import javax.servlet.jsp.JspException; import javax.servlet.jsp.tagext.SimpleTagSupport;
import com.bmw.candy.candiedServices.SubscriptionAccess; import com.bmw.candy.candiedServices.data.Subscription;
/**
* Get the information on a subscription and store it in some JSP variables.
*/
public class TagSubscriptionInfo extends SimpleTagSupport {
/** The ID of the subscription to obtain info on. */
private long targetID = -1;
/** The variable in which to store the subscription name. */ private String nameVar = null;
/** The variable in which to store the subscription description. */ private String descriptionVar = null;
/** The variable in which to store the subscription items. */ private String itemsVar = null;
/** The variable in which to store the subscription last sequence number. */
private String sequenceNumVar = null;
/** [EMAIL PROTECTED] */
public void doTag() throws JspException, IOException {
if (this.targetID < 0)
throw new IllegalArgumentException("targetID"); //$NON-NLS-1$
SubscriptionAccess access = new SubscriptionAccess();
Subscription subscription = access.getSubscriptionInfo(this.targetID);
if (this.nameVar != null) {
getJspContext().setAttribute(this.nameVar, subscription.getName());
}
if (this.descriptionVar != null) {
getJspContext().setAttribute(this.descriptionVar,
subscription.getDescription());
}
if (this.itemsVar != null) {
getJspContext().setAttribute(this.itemsVar, subscription.getItems());
}
if (this.sequenceNumVar != null) {
getJspContext().setAttribute(this.sequenceNumVar,
new
Integer(subscription.getSequenceNum()));
}
}
/**
* @param descriptionVar The variable in which to store the subscription
description.
*/
public void setDescriptionVar(String descriptionVar) {
this.descriptionVar = descriptionVar;
}
/**
* @param itemVar The variable in which to store the subscription items.
*/
public void setItemsVar(String itemsVar) {
this.itemsVar = itemsVar;
}
/**
* @param nameVar The variable in which to store the subscription name.
*/
public void setNameVar(String nameVar) {
this.nameVar = nameVar;
}
/** * @param targetID The ID of the subscription to obtain info on. */ public void setTargetID(long targetID) { this.targetID = targetID; }
/**
* @param sequenceNumVar The variable in which to store the subscription
last sequence number.
*/
public void setSequenceNumVar(String sequenceNumVar) {
this.sequenceNumVar = sequenceNumVar;
}
}
So what Might I be doing wrong? I have googled for this for hours on end with no enlightenment. I am currently using the jsp:attribute tag to work around this but would really like to fix this once and for all.
Thanks in advance.
-- Robert
------------------------------------------------------------------------
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
------------------------------------------------------------------------
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]