How to embed the <jsp:plugin> tag into a tag handler class...HELP !!

J

jstack

Hello,

I have a custom tag class with the following : -

public int doStartTag() throws JspException {
try
{
StringBuffer sBuffer = new StringBuffer();
JspWriter out = pageContext.getOut();
sBuffer.append("<jsp:plugin type=\"applet\"");
sBuffer.append(" ");
sBuffer.append("codebase=\"/homer/jsp/applet\"");
sBuffer.append(" ");
sBuffer.append("code=\"HelloWorld.class\"");
sBuffer.append(" ");
sBuffer.append("width=\"300\"");
sBuffer.append(" ");
sBuffer.append("height=\"300\"");
sBuffer.append(">");
//sBuffer.append("</jsp:plugin>");
out.print(sBuffer.toString());


}
catch (IOException ioe)
{
throw new JspException("Error: IOException while writing to client" +
ioe.getMessage());
}

return EVAL_BODY_INCLUDE;
}

public int doEndTag() throws JspException {

try
{
JspWriter out = pageContext.getOut();
out.print("</jsp:plugin>");
}
catch (IOException ioe)
{
throw new JspException("Error: IOException while writing to client" +
ioe.getMessage());
}


return EVAL_PAGE;
}


I am trying to create a custom tag that will download the java plugin
if its not present. I am hoping too to pass in the arguments like
codebase, applet etc into it. When I do a View Source the file looks
like this


<HTML>
<HEAD>
<TITLE>Hello Tag</TITLE>
</HEAD>

<BODY bgcolor="#ffffcc">
<B>My first tag prints</B>:
<jsp:plugin type="applet" codebase="/homer/jsp/applet"
code="HelloWorld.class" width="300" height="300">
</jsp:plugin>
</BODY>
</HTML>

The 'my first tag' gets printed to the screen and thats all that
happens. Nothing else.



<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib
PUBLIC "-//Sun Microsystems, Inc.// DTD JSP Tag Library 1.1//EN"

"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">


<!-- a tag library descriptor -->

<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>first</shortname>
<uri></uri>
<info>A simple tab library for the examples</info>

<tag>
<name>hello</name>
<tagclass>tags.HelloTag</tagclass>
<bodycontent>JSP</bodycontent>
</tag>
</taglib>

Can someone please help.


Thanks again,
jstack
 

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,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top