Hi All,
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
-
How to catch values from a JSP Tag library (2 messages)
- Posted by: K Srinivasa Rao
- Posted on: February 28 2001 02:42 EST
Threaded Messages (2)
- How to catch values from a JSP Tag library by Gordon Reynolds on February 28 2001 14:25 EST
- How to catch values from a JSP Tag library by Srinivas Janakiraman on February 28 2001 15:51 EST
-
How to catch values from a JSP Tag library[ Go to top ]
- Posted by: Gordon Reynolds
- Posted on: February 28 2001 14:25 EST
- in response to K Srinivasa Rao
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();
try
{
out.println("<h1>");
out.println("Hello World!")
out.println("</h1>");
}
catch(IOException e)
{
throw new JspTagException("Unable to write tag output");
}
...
return SKIP_BODY;
}
Regards,
Gordon. -
How to catch values from a JSP Tag library[ Go to top ]
- Posted by: Srinivas Janakiraman
- Posted on: February 28 2001 15:51 EST
- in response to Gordon Reynolds
Srini,
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
Srinivas.J