FileDocCategorySizeDatePackage
FileTag.javaAPI DocGlassfish v2 API4504Sat May 05 19:17:12 BST 2007org.apache.taglibs.standard.examples.taglib

FileTag

public class FileTag extends javax.servlet.jsp.tagext.TagSupport

Tag handler for <file>

author
Pierre Delisle
version
$Revision: 1.3 $ $Date: 2007/05/06 02:17:11 $

Fields Summary
private String
id
private String
file
private Reader
reader
Constructors Summary
public FileTag()

        super();
        init();
    
Methods Summary
public intdoEndTag()

        try {
            reader.close();
        } catch (IOException ex) {}
        reader = null;
        return EVAL_PAGE;
    
public intdoStartTag()

        reader = getReaderFromFile(file);
        exposeVariable(reader);
        return EVAL_BODY_INCLUDE;
    
private voidexposeVariable(java.io.Reader reader)

        if (id != null) {
            pageContext.setAttribute(id, reader);
        }
    
public java.io.ReadergetReaderFromFile(java.lang.String name)

        InputStream in = pageContext.getServletContext().
            getResourceAsStream(name);
        if (in == null) {
            throw new JspException("Could not access " + name);
        }

        return new InputStreamReader(in);
    
private voidinit()

        id = null;
        file = null;
    
public voidrelease()
Releases any files we may have (or inherit)

        super.release();
        init();
    
public voidsetId(java.lang.String id)
Tag's 'id' attribute

        this.id = id;
    
public voidsetfile(java.lang.String file)
Tag's 'file' attribute

        this.file = file;