File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes what is getValue(String) in custom tag? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "what is getValue(String) in custom tag?" Watch "what is getValue(String) in custom tag?" New topic

what is getValue(String) in custom tag?

Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
This is a class from the Sun J2EE reference example. It extends TagSupport and makes several calls to getValue(String) and setValue(String, Object). What are these methods doing and/or what are they get/setting? It looks like some session or request scoped objects, but where are they coming from? Any ideas where I can find docs for classes like TagSupport (javax classes)? Thanks

public class CreateTemplateTag extends TagSupport {
public int doStartTag() {
Hashtable screens = null;
// check for the template and create if it does not exist
if (templateName != null){
screens = (Hashtable)getValue("screens");
if (screens == null) {
setValue("screens", new Hashtable());
} else Debug.println("CreateTemplateTag: screens exits ");
} catch (Exception e){
Debug.println("CreateTemplateTag: Error in doStartTag: " + e);
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
The javax.servlet.jsp.tagext.TagSupport class has a built in Hashtable called values. Just a convenience item so that your tag can keep stuff around.
I am working from the doc files and source files included with the Tomcat servlet engine release ( to find this out. Doesn't the J2EE release include these docs?
Tony Alicea

Joined: Jan 30, 2000
Posts: 3226
The J2EE Javadoc documentation is a separate download... The online Doc is in

Tony Alicea
Senior Java Web Application Developer, SCPJ2, SCWCD
Dani Mazzuca
Ranch Hand

Joined: May 21, 2003
Posts: 70
The TagSupport setValue(), getValue(), etc. methods are intended to be used for nested cooperating tags, to share some dynamically created objects. The enclosing tag creates an objects an puts it using setValue(). The object is available to all inner tag handlers through the use of ((TagSupport)getParent()).getValue(name). It is the same as using pageContext.getAttribute() or pageContext.setAttribute(), however, in this case it uses a private namespace for the nested tags handlers, instead of a common general one.

See “Cooperating Tags” in the J2ee tutorial

I agree. Here's the link:
subject: what is getValue(String) in custom tag?
It's not a secret anymore!