⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 passwordtag.java

📁 Servlet与JSP核心编程原码,适合刚做软件开发的程序员参考!
💻 JAVA
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -