📄 onlinetag.java
字号:
package org.jetic.web.techbbs;import java.sql.*;import javax.servlet.jsp.*;import javax.servlet.jsp.tagext.*;/** * Title: 华源技术论坛 * Description: * Copyright: Copyright (c) 2001 * Company: GBSOURCE * @author fainter * @version 1.0 */public class onlineTag extends BodyTagSupport { private ResultSet rs = null; private int id = 0; private int time = 0 ; public int doStartTag() throws javax.servlet.jsp.JspException { try { Mssql conn = new Mssql(); String sql="select id,datediff(minute,getdate()-0.01,fdtime) as online,userid,fdcip,fdcact from tbonline order by fdtime desc"; rs = conn.executeQuery(sql); if (rs.next()) { id = rs.getInt("id"); time = rs.getInt("online"); if(time>0) { pageContext.setAttribute("userid", new String(rs.getString("userid"))); pageContext.setAttribute("ip", new String(rs.getString("fdcip"))); pageContext.setAttribute("act", new String(rs.getString("fdcact"))); pageContext.setAttribute("time", new Integer(15-time)); } else conn.executeUpdate("delete from tbonline where id = " + id); return EVAL_BODY_TAG; } else { return SKIP_BODY; } } catch (Exception ex) { System.err.print("BoardlistTag.doStartTag():"); ex.printStackTrace(System.err); return SKIP_BODY; } } public int doAfterBody() throws javax.servlet.jsp.JspException { BodyContent body = getBodyContent(); try { if (rs.next()) { id = rs.getInt("id"); time = rs.getInt("online"); if(time>0) { pageContext.setAttribute("userid", new String(rs.getString("userid"))); pageContext.setAttribute("ip", new String(rs.getString("fdcip"))); pageContext.setAttribute("act", new String(rs.getString("fdcact"))); pageContext.setAttribute("time", new Integer(15-time)); } else { try{ Mssql conn = new Mssql(); conn.executeUpdate("delete from tbonline where id = " + id); } catch (Exception ex) { System.err.print("BoardlistTag.doStartTag():"); ex.printStackTrace(System.err); } } return EVAL_BODY_TAG; } else { body.writeOut(body.getEnclosingWriter()); return SKIP_BODY; } } catch (Exception ex) { System.err.print("BoardlistTag.doStartTag():"); ex.printStackTrace(System.err); return SKIP_BODY; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -