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

📄 useridtag.java

📁 Servlet与JSP核心编程原码,适合刚做软件开发的程序员参考!
💻 JAVA
字号:
package examples;import javax.servlet.jsp.tagext.*;import javax.servlet.jsp.*;import java.io.Writer;/** * Example2: A connection/query tag. * This is the userid 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. * * <userId><%= some expr...%></userId> */public class UserIdTag extends BodyTagSupport {    /**     * Create a new UserIdTag     */    public UserIdTag() {	super();    }    /**     * Attributes for this action:     * NONE     */    /**     * Process a start tag.     * Find the enclosing connection tag and keep a reference aside.     *     * @return evaluate the body     */    public int doStartTag() throws JspTagException {	myConnection	    = (ConnectionTag) findAncestorWithClass(this,						    ConnectionTag.class);	if (myConnection == null) {	    throw new JspTagException("userid must be inside a connection");	}	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();	// Convert to String for use	myConnection.setUserId(body.getString());	// Clean up	body.clearBody();		// Do not reevaluate the body	return SKIP_BODY;    }    // variables    private ConnectionTag myConnection; }

⌨️ 快捷键说明

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