Web tier: servlets, JSP, Web frameworks: How to catch values from a JSP Tag library
- Posted by: K Srinivasa Rao
- Posted on: February 28 2001 02:42 EST
I have a problem. I have a custom tag which takes two attributes and validates inside the class. OK. I want to return a value to the JSP from the Tag class. where should i write code for that. How to return a value to a JSP page
Srinivasa, to return a value from your tag handler to the JSP page, you'd write code the doStartTag() method of your tag handler that looks something like this:
public int doStartTag() throws JspException
JspWriter out = pageContext.getOut();
throw new JspTagException("Unable to write tag output");
The sample code by Gordon will write the output of the tag to the JSP page.
If you want to pass value from the tag to JSP(for example storing some value in a variable in the tag and accessing in the JSP) you have to use TagExtraInfo class and define your variable and then can use it in the JSP.
For further details refer http://www.weblogic.com/docs51/classdocs/API_taglib.html