public class ValidateSessionTag extends TagSupport {
private static final long serialVersionUID = 1L;
private String client = "client";
private String page = "index.jsp";
/*
* (non-Javadoc)
* @see javax.servlet.jsp.tagext.Tag#doEndTag()
*/
public int doEndTag() throws JspException{
boolean valid = false;
HttpSession session = pageContext.getSession();
if(session.getAttribute(client) != null && session != null){
valid = true;
}
if(valid){
return EVAL_PAGE;
}
//the session value is losted
else {
try {
//这里出错,出错信息见后面
pageContext.forward(page);
} catch (Exception e) {
CommonLogger.error(e.getMessage());
throw new JspException(e.toString());
}
return (SKIP_PAGE);
}
}
/*
* (non-Javadoc)
* @see javax.servlet.jsp.tagext.Tag#doStartTag()
*/
public int doStartTag() throws JspException {
return (SKIP_BODY);
} /**
* @return Returns the client.
*/
public String getClient() {
return client;
} /**
* @param client The client to set.
*/
public void setClient(String client) {
this.client = client;
} /**
* @return Returns the page.
*/
public String getPage() {
return page;
} /**
* @param page The page to set.
*/
public void setPage(String page) {
this.page = page;
}
/**
* reset the value
*/
public void release() {
super.release();
this.client = MpfWebConstants.MPF_USER_INFO;
this.page = MpfWebConstants.MPF_LOGIN_PAGE;
}
}出错信息提示:
java.lang.IllegalStateException: Cannot forward a response that is already committed请各位兄弟不惜赐教,谢谢
private static final long serialVersionUID = 1L;
private String client = "client";
private String page = "index.jsp";
/*
* (non-Javadoc)
* @see javax.servlet.jsp.tagext.Tag#doEndTag()
*/
public int doEndTag() throws JspException{
boolean valid = false;
HttpSession session = pageContext.getSession();
if(session.getAttribute(client) != null && session != null){
valid = true;
}
if(valid){
return EVAL_PAGE;
}
//the session value is losted
else {
try {
//这里出错,出错信息见后面
pageContext.forward(page);
} catch (Exception e) {
CommonLogger.error(e.getMessage());
throw new JspException(e.toString());
}
return (SKIP_PAGE);
}
}
/*
* (non-Javadoc)
* @see javax.servlet.jsp.tagext.Tag#doStartTag()
*/
public int doStartTag() throws JspException {
return (SKIP_BODY);
} /**
* @return Returns the client.
*/
public String getClient() {
return client;
} /**
* @param client The client to set.
*/
public void setClient(String client) {
this.client = client;
} /**
* @return Returns the page.
*/
public String getPage() {
return page;
} /**
* @param page The page to set.
*/
public void setPage(String page) {
this.page = page;
}
/**
* reset the value
*/
public void release() {
super.release();
this.client = MpfWebConstants.MPF_USER_INFO;
this.page = MpfWebConstants.MPF_LOGIN_PAGE;
}
}出错信息提示:
java.lang.IllegalStateException: Cannot forward a response that is already committed请各位兄弟不惜赐教,谢谢
我把这里的page 改成/contextPath/index.jsp, 出现空白页面,请再一次指教