📄 newtag.java
字号:
package org.jetic.web.techbbs;import java.sql.*;import javax.servlet.jsp.*;import javax.servlet.jsp.tagext.*;import org.jetic.util.Format;import java.text.SimpleDateFormat;/** * Title: 华源技术论坛 * Description: * Copyright: Copyright (c) 2001 * Company: GBSOURCE * @author fainter * @version 1.0 */public class newTag extends BodyTagSupport { private ResultSet rs = null; private Format format = new Format(); private SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); public int doStartTag() throws javax.servlet.jsp.JspException { try { Mssql conn = new Mssql(); String sql="select top 10 id,fdimain,fditopic,fdiicon,fdctitle,fdcwriter,fdtime from tbtopic order by id desc"; rs = conn.executeQuery(sql); if (rs.next()) { pageContext.setAttribute("articleID", new Integer(rs.getInt("ID"))); pageContext.setAttribute("boardID", new Integer(rs.getInt("fdimain"))); pageContext.setAttribute("topic", new Integer(rs.getInt("fditopic"))); pageContext.setAttribute("icon", new Integer(rs.getInt("fdiicon"))); pageContext.setAttribute("title", new String(format.toHtml(rs.getString("fdctitle")))); pageContext.setAttribute("writer", new String(rs.getString("fdcwriter"))); pageContext.setAttribute("time", new String(formatter.format(rs.getTimestamp("fdtime")))); 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()) { pageContext.setAttribute("articleID", new Integer(rs.getInt("ID"))); pageContext.setAttribute("boardID", new Integer(rs.getInt("fdimain"))); pageContext.setAttribute("topic", new Integer(rs.getInt("fditopic"))); pageContext.setAttribute("icon", new Integer(rs.getInt("fdiicon"))); pageContext.setAttribute("title", new String(format.toHtml(rs.getString("fdctitle")))); pageContext.setAttribute("writer", new String(rs.getString("fdcwriter"))); pageContext.setAttribute("time", new String(formatter.format(rs.getTimestamp("fdtime")))); 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 + -