nametag.java
来自「学生信息管理系统」· Java 代码 · 共 57 行
JAVA
57 行
package tagext;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.Tag;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import java.io.IOException;
import javax.servlet.http.HttpSession;
public class NameTag implements Tag
{
private PageContext context=null;
private Tag parent=null;
private String userName=null;
public void setPageContext(PageContext context)
{
this.context=context;
}
public void setParent(Tag parent)
{
this.parent=parent;
}
public void setUserName(String userName)
{
this.userName = userName;
}
public Tag getParent()
{
return this.parent;
}
public int doStartTag()throws JspException
{
JspWriter out=this.context.getOut();
HttpSession session= this.context.getSession();
String user=(String)session.getAttribute(userName);
try
{
out.print(user);
}
catch(IOException ioe)
{
ioe.printStackTrace();
}
return this.SKIP_BODY;
}
public int doEndTag()throws JspException
{
return this.EVAL_PAGE;
}
public void release()
{
this.context=null;
this.parent=null;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?