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

Discussion in 'Java' started by jstack, Jul 4, 2003.

  1. jstack

    jstack Guest

    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
     
    jstack, Jul 4, 2003
    #1
    1. Advertising

  2. (jstack) writes:

    > JspWriter out = pageContext.getOut();


    You may want to use BodyTag.setBodyContent() instead, and set your tag
    in that.

    > sBuffer.append("<jsp:plugin type=\"applet\"");


    .... so that this JSP tag gets evaluated.

    > return EVAL_BODY_INCLUDE;


    Should be EVAL_BODY_BUFFERED
     
    Tor Iver Wilhelmsen, Jul 4, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Raymond DeCampo

    Custom tags and <jsp:plugin> / <jsp:param>

    Raymond DeCampo, Feb 18, 2004, in forum: Java
    Replies:
    0
    Views:
    639
    Raymond DeCampo
    Feb 18, 2004
  2. Replies:
    5
    Views:
    894
    Chris Smith
    Sep 18, 2005
  3. shruds
    Replies:
    1
    Views:
    835
    John C. Bollinger
    Jan 27, 2006
  4. Replies:
    1
    Views:
    731
  5. sugapablo
    Replies:
    0
    Views:
    2,163
    sugapablo
    Sep 21, 2007
Loading...

Share This Page