FileDocCategorySizeDatePackage
DriverTag.javaAPI DocGlassfish v2 API5353Sat May 05 19:17:54 BST 2007org.apache.taglibs.standard.tag.common.sql

DriverTag

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

Tag handler for <Driver> in JSTL, used to create a simple DataSource for prototyping.

author
Hans Bergsten

Fields Summary
private static final String
DRIVER_CLASS_NAME
private static final String
JDBC_URL
private static final String
USER_NAME
private static final String
PASSWORD
private String
driverClassName
private String
jdbcURL
private int
scope
private String
userName
private String
var
Constructors Summary
Methods Summary
public intdoStartTag()

	DataSourceWrapper ds = new DataSourceWrapper();
	try {
	ds.setDriverClassName(getDriverClassName());
	}
	catch (Exception e) {
	    throw new JspTagException("Invalid driver class name: " +
		e.toString(), e);
	}
	ds.setJdbcURL(getJdbcURL());
	ds.setUserName(getUserName());
	ds.setPassword(getPassword());
	pageContext.setAttribute(var, ds, scope);
	return SKIP_BODY;
    
private java.lang.StringgetDriverClassName()

	if (driverClassName != null) {
	    return driverClassName;
	}
	ServletContext application = pageContext.getServletContext();
	return application.getInitParameter(DRIVER_CLASS_NAME);
    
private java.lang.StringgetJdbcURL()

	if (jdbcURL != null) {
	    return jdbcURL;
	}
	ServletContext application = pageContext.getServletContext();
	return application.getInitParameter(JDBC_URL);
    
private java.lang.StringgetPassword()

	ServletContext application = pageContext.getServletContext();
	return application.getInitParameter(PASSWORD);
    
private java.lang.StringgetUserName()

	if (userName != null) {
	    return userName;
	}
	ServletContext application = pageContext.getServletContext();
	return application.getInitParameter(USER_NAME);
    
public voidsetDriver(java.lang.String driverClassName)


    //*********************************************************************
    // Accessor methods

        
	this.driverClassName = driverClassName;
    
public voidsetJdbcURL(java.lang.String jdbcURL)

	this.jdbcURL = jdbcURL;
    
public voidsetScope(java.lang.String scopeName)
Setter method for the scope of the variable to hold the result.

        if ("page".equals(scopeName)) {
            scope = PageContext.PAGE_SCOPE;
        }
        else if ("request".equals(scopeName)) {
            scope = PageContext.REQUEST_SCOPE;
        }
        else if ("session".equals(scopeName)) {
            scope = PageContext.SESSION_SCOPE;
        }
        else if ("application".equals(scopeName)) {
            scope = PageContext.APPLICATION_SCOPE;
        }
    
public voidsetUserName(java.lang.String userName)

	this.userName = userName;
    
public voidsetVar(java.lang.String var)

	this.var = var;