For Programmers: Free Programming Magazines  


Home > Archive > Java Help > September 2004 > how to write jsp custom tag that can have all kind of jsp elements









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author how to write jsp custom tag that can have all kind of jsp elements
Lukasz Indyk

2004-09-22, 9:10 am

i want to write jsp custom tag that prints string "begin", then invokes
all jsp instructions from it's body (instructions == other tags and
scriplets), and then prints string "end". i've tried to write it by
extending SimpleTagSupport class, and coding sth like that:

public void doStartTag() throws JspException {
JspWriter out = getJspContext().getOut();

try{
out.println("begin");
getJspBody().invoke(null);
out.println("end");
} catch (IOException e) {
throw new JspTagException("RuleFileTd tag exception :" +
e.getMessage());
}
}

the class with above method compiles without errors. this is a
body-content tag of my custom tag definition in tld file i use:

<body-content>JSP</body-content>

but during execution of my jsp page tomcat gives me error saying that
body-content cannot be set to JSP while using SimpleTagSupport.

what to do now? maybe i should extend other class to write my tag? how
to implement a tag that allows other tags and scriplets in his body?
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com