FileDocCategorySizeDatePackage
SimpleLogoTag.javaAPI DocExample1918Wed Jun 25 09:49:08 BST 2003com.jspservletcookbook

SimpleLogoTag

public class SimpleLogoTag extends SimpleTagSupport
This tag generates a thumbnail image using HTML img tag, next to text message. The user specifies the content of the message and the Heading level (i.e.,

-

)

Fields Summary
private String
heading
private String
image
private String
width
private String
height
Constructors Summary
Methods Summary
public voiddoTag()


       
  
  JspContext jspContext = getJspContext();
  
    //this method assumes that attribute properties have been set.
    try {
    
    int h = new Integer(heading).intValue();
    
    if(! (h > 0 && h < 7))
        throw new JspException("The 'heading' attribute value must between 1 and 6 inclusive.");
        
    } catch (Exception e) { throw new JspException(e.getMessage()); }
    
    
    JspWriter out = jspContext.getOut();
    
    String imgDir = (String) jspContext.findAttribute("imgDir");
    
    if (imgDir == null || "".equals(imgDir))
         throw new JspException(
         "No attribute provided specifying the application's image directory.");
    

   
   out.println(new StringBuffer("<img src=\"").append(imgDir).append(image).append("\" width=\"").append(width).append("\" height=\"").append(height).append("\" align=\"left\">").append("<H").append(heading).append(">").toString()); 
getJspBody().invoke(null);
out.println(new StringBuffer("</H").append(heading).append(">").toString());

  
  
public voidsetHeading(java.lang.String level)


    this.heading= level;

  
public voidsetHeight(java.lang.String height)


    this.height = height;

  
public voidsetImage(java.lang.String name)


    this.image = name;

  
public voidsetWidth(java.lang.String width)


    this.width = width;