ItemLook.java
资源名称:wapjsp.rar [点击查看]
上传用户:xiao85513
上传日期:2010-01-11
资源大小:2160k
文件大小:3k
源码类别:
手机WAP编程
开发平台:
Java
- package tagclass;
- import javax.servlet.jsp.*;
- import javax.servlet.jsp.tagext.*;
- import java.sql.*;
- import java.util.Vector;
- public class ItemLook extends TagSupport
- {
- private String delpage="";
- public String getDelpage()
- {
- return this.delpage;
- }
- public void setDelpage(String newdelpage)
- {
- this.delpage=newdelpage;//delpage=“”时代表无删除操作,delpage!=""时的值代表删除时执行页面
- }
- public String toChinese(String str)
- {
- try{
- String t=new String(str.getBytes("gb2312"), "ISO8859_1");
- return t;
- }
- catch(Exception e){return null;}
- }
- public int doStartTag() throws JspException
- {
- try
- {
- //jsp:连接mysql数据库
- pageContext.getOut().print("<table>");
- Class.forName("org.gjt.mm.mysql.Driver").newInstance();
- String url = "jdbc:mysql://localhost/picring?user=nangua&password=2003herald&useUnicode=true&characterEncoding=8859_1";
- Connection con = DriverManager.getConnection(url);
- Statement statement = con.createStatement();
- ResultSet rsbig = statement.executeQuery(
- "select id,classname from bigclass order by id asc");
- Vector bigclassid = new Vector();
- Vector bigclassname = new Vector();
- while (rsbig.next()) {
- bigclassname.add(rsbig.getString("classname"));
- bigclassid.add(rsbig.getString("id"));
- }
- rsbig.close();
- int i = 0;
- while (i < bigclassname.size()) {
- pageContext.getOut().print(
- "<tr><td align="right" valign=top><B>");
- pageContext.getOut().print(bigclassname.get(i).toString());
- ////////////////////
- if(this.getDelpage()!="")pageContext.getOut().print("</B> <a href='"+this.getDelpage()+"&delclass=bigclass&delid="+bigclassid.get(i).toString()+"'>"+toChinese("删除")+"</a>");
- ////////////////////
- pageContext.getOut().print(
- "<B>---</B></td><td width="150" align="left" valign=top>");
- ResultSet rssmall = statement.executeQuery(
- "select id,classname from smallclass where parentid=" +
- Integer.parseInt(bigclassid.get(i).toString()));
- int flag = 0;
- while (rssmall.next()) {
- pageContext.getOut().print(rssmall.getString("classname"));
- ////////////////////
- if(this.getDelpage()!="")pageContext.getOut().print(" <a href='"+this.getDelpage()+"&delclass=smallclass&delid="+rssmall.getString("id")+"'>"+toChinese("删除")+"</a>");
- ////////////////////
- pageContext.getOut().print("<BR>");
- flag = 1;
- }
- rssmall.close();
- //String s="暂无子栏目";
- //String t=new String(s.getBytes("gb2312"), "ISO8859_1");
- if (flag == 0) {
- pageContext.getOut().print("<font color=gray>"+toChinese("暂无子栏目")+"</font>");
- }
- i++;
- pageContext.getOut().print(
- "</td></tr><tr colspan=2 height=15><Td> </td></tr>");
- }
- con.close();
- pageContext.getOut().print("</table>");
- }
- catch(Exception e)
- {
- throw new JspException(e);
- }
- return SKIP_BODY;
- }
- }