Question

I need to get the name of requester tag at doStartTag function I have this Custom tag in .tld

<tag>
    <name>Resource</name>
    <tag-class>Mirnint.Interface.Tag.MNIT_Resources</tag-class>
    <body-content>JSP</body-content>
    <attribute>
        <name>Style</name>
        <required>false</required>
    </attribute>
    <attribute>
        <name>JavaScript</name>
        <required>false</required>
    </attribute>
</tag>

and in JSP :-

<%@ taglib uri="/webapp/Min" prefix="Min"%>
<html>
<head>
    <Min:Resource/>
</head>

and java class is :-

@Override
public int doStartTag() throws JspException {
//Here i need to print the name of caller tag in this example it should be ("Resource")...
System.out.println(**The Name of Tag**);
}

Thou output Should be

Resource

Thanks for help...

Was it helpful?

Solution

You need to create a getter/setter corresponding to name; then your code would be like:

public class Hello extends TagSupport {
    private String name=null;
    /**
      * Getter/Setter for the attribute name as defined in the tld file 
      * for this tag
      */
public void setName(String value){
    name = value;
}

    public String getName(){
          return(name);
       }
/**
* doStartTag is called by the JSP container when the tag is encountered
*/
    public int doStartTag() {
    System.out.println(name);
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top