passwordtag.java

来自「It gives some some of examples of java s」· Java 代码 · 共 69 行

JAVA
69
字号
package examples;import javax.servlet.jsp.*;import javax.servlet.jsp.tagext.*;import java.io.Writer;/** * Example2: A connection/query tag. * This is the password entry. * * The data is stored up into the containing <connection> tag. * It is an error (currently only detected at run-time) not to have * a containing <connection> tag instance. * * <password><%= some expr...%></password> */public class PasswordTag extends BodyTagSupport {    /**     * Create a new PasswordTag     */    public PasswordTag() {	super();    }    /**     * Attributes for this action:     * NONE     */    /**     * Process a start tag.     * Find the enclosing connection tag and save the reference away.     *     * @return EVAL_BODY     */    public int doStartTag() throws JspTagException {	myConnection =	    (ConnectionTag) findAncestorWithClass(this,						  ConnectionTag.class);	if (myConnection == null) {	    throw new JspTagException("password action must be inside connection action");	}	return EVAL_BODY_TAG;    }    /**     * After body evaluation.     * Extract a string from the nested stream.     *     * @param body the BodyContent for this tag     * @return SKIP_BODY     */    public int doAfterBody() {	BodyContent body = getBodyContent();	myConnection.setPassword(body.getString());	body.clearBody();	// clean after ourselves		return SKIP_BODY;		// do not reevaluate the body    }    // variables    private ConnectionTag myConnection; }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?