Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJWCD
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Ron McLeod
Paul Clapham
Tim Cooke
Devaka Cooray
Sheriffs:
Liutauras Vilda
paul wheaton
Rob Spoor
Saloon Keepers:
Tim Moores
Stephan van Hulst
Tim Holloway
Piet Souris
Mikalai Zaikin
Bartenders:
Carey Brown
Roland Mueller
Forum:
Web Component Certification (OCEJWCD)
Problem in displaying dynamic attributes
Pawan Arora
Ranch Hand
Posts: 105
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
I'm trying to process dynamic attributes in
Jsp
, but I'm getting display nothing in response.
Here's the JSP code:
<%@ taglib prefix="mine" uri="DiceFunctions" %> <html><body> <mine:advice suggest="nothing" > </mine:advice> </body></html>
The TLD file, which is in WEB-INF folder:
<?xml version="1.0" encoding="ISO-8859-1"?> <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"> <tlib-version>1.2</tlib-version> <jsp-version>2.0</jsp-version> <uri>DiceFunctions</uri> <tag> <name>advice</name> <tag-class>foo.AdvisorTagHandler</tag-class> <body-content>scriptless</body-content> <dynamic-attributes>true</dynamic-attributes> </tag>
and the tag handler class:
package foo; import javax.servlet.jsp.JspException; import javax.servlet.jsp.tagext.*; import java.io.*; import javax.servlet.jsp.*; import java.util.*; public class AdvisorTagHandler extends TagSupport implements DynamicAttributes { private Map<String,Object> tagAttrs=new HashMap<String,Object>(); public int doStartTag() throws JspException{ try{ for(String attr: tagAttrs.keySet()) { String attrd=String.format("%s='%s'",tagAttrs.get(attr)); pageContext.getOut().print(attrd); } } catch(Exception e) { e.getMessage(); } return SKIP_BODY; } public void setDynamicAttribute(String uri, String name, Object value){ tagAttrs.put(name,value); } public int doEndTag() throws JspException{ return EVAL_PAGE; }
what's modification do I've to do to display dynamic attributes value?
Thanks in advance.
Chinmaya Chowdary
Ranch Hand
Posts: 437
I like...
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi Pawan. Use
String attrd=String.format("%s='%s'", attr, tagAttrs.get(attr));
in AdviceTagHandler.
SCJP5.0, SCWCD5.0, OCEJPAD6, OCPJWSD6
Pawan Arora
Ranch Hand
Posts: 105
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks.
I'm just a poor boy, I need no sympathy, because I'm easy come, easy go, little high, little low, little ad
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
TLD file
Problem While using EL
org.apache.jasper.JasperException: Unable to compile class for JSP:
Custom tags Problem
Question on Empty body content of Simple Tag Handlers
More...