how to write jsp custom tag that can have all kind of jsp elements(not only other tags but also srci

L

Lukasz Indyk

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top