📄 checklogontag.java
字号:
/*
* Created on 2004-4-1
*
*/
package com.esimple.service.rbac.view.taglib;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
import com.esimple.service.rbac.*;
/**
* @author steven
*
*/
public class CheckLogonTag extends TagSupport {
private String name = User.SESSION_KEY;
private String page = "/internet/reLogin.jsp";
/**
* Return the forward page.
*/
public String getPage() {
return (this.page);
}
/**
* Set the forward page.
*
* @param page The new forward page
*/
public void setPage(String page) {
this.page = page;
}
public int doStartTag() throws JspException {
return (SKIP_BODY);
}
public int doEndTag() throws JspException {
// Is there a valid user logged on?
boolean valid = false;
HttpSession session = pageContext.getSession();
if ((session != null) && (session.getAttribute(name) != null)) {
valid = true;
}
// Forward control based on the results
if (valid) {
return (EVAL_PAGE);
} else {
try {
pageContext.forward( page );
} catch (ServletException e) {
throw new JspException(e.toString());
} catch (IOException e) {
throw new JspException(e.toString());
}
return (SKIP_PAGE);
}
}
/**
* Release any acquired resources.
*/
public void release() {
super.release();
this.page = "/internet/reLogin.jsp";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -