⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 paperedit.jsp

📁 jsp动态网站开发与实例(第3版) 源码
💻 JSP
字号:
<%@page contentType="text/html"%><%@page pageEncoding="GB2312"%><%@page import = "java.sql.*" %><%@page import ="java.util.*,java.io.*"%><%@page import ="javax.mail.*"%><%@page import ="javax.mail.internet.*"%><%@page import ="javax.activation.*"%><%    request.setCharacterEncoding("GB2312") ;     String editType=request.getParameter("editType");     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");    Connection con = DriverManager.getConnection("jdbc:odbc:paper");    Statement smt =con.createStatement          (ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);    String editSQL = ""   ;     boolean  editState=false;    String title = request.getParameter("title") ;     String content = request.getParameter("content") ;         if(editType.equals("new")){        editSQL = "INSERT INTO paper" +                     "(papertitle,papercontent)VALUES" +                     "('"+title+"','"+content+"')" ;         smt.execute(editSQL) ;          out.println("电子报新增完成 !!") ;    }         if(editType.equals("update")){        String paperid = request.getParameter("paperid") ;         editSQL = "UPDATE paper SET " +                         "papertitle='"+title+"'," +                         "papercontent='"+content+"' " +                    "WHERE " +                         "paperid=" + paperid ;         smt.execute(editSQL) ;         out.println("电子报修改完成 !!") ;     }              if(editType.equals("published")){                String paperid = request.getParameter("paperid") ;         String paperSQL="SELECT * FROM paper WHERE paperid=" +  paperid;         ResultSet theResultpaper = smt.executeQuery(paperSQL) ;        theResultpaper.next() ;         String titlepublished = theResultpaper.getString("papertitle") ;        String contentpublished = theResultpaper.getString("papercontent") ;                theResultpaper.close() ;                         Properties theProperties = System.getProperties() ;         theProperties.put("mail.host","127.0.0.1") ;         theProperties.put("mail.transport.protocol","smtp") ;                String listSQL="SELECT * FROM list WHERE cancel=false" ;         ResultSet theResult = smt.executeQuery(listSQL) ;        while(theResult.next()) {                     String mail = theResult.getString("mail") ;                 Session theSession = Session.getDefaultInstance(theProperties,null) ;             theSession.setDebug(false) ;                 MimeMessage theMessage = new MimeMessage(theSession) ;                             theMessage.setFrom(new InternetAddress("jsppaper@jspmail.com.tw") ) ;                     theMessage.setRecipients(Message.RecipientType.TO,mail) ;             theMessage.setSubject(titlepublished) ;                    theMessage.setText(contentpublished, "Big5") ;             Transport.send(theMessage) ;         }                GregorianCalendar theGregorianCalendar=new GregorianCalendar() ;         String publishdate = theGregorianCalendar.get(Calendar.YEAR)+"/"+                theGregorianCalendar.get(Calendar.MONTH)+"/"+                theGregorianCalendar.get(Calendar.DAY_OF_MONTH)  ;                        editSQL = "UPDATE paper SET " +                         "publishdate='"+publishdate+"', " +                         "published=true " +                    "WHERE " +                         "paperid=" + paperid ;         smt.execute(editSQL) ;                        out.println("电子报已发行 !!") ;                  } %><html>       <head><title>管理员登录网页</title></head>    <body>        <br>        <a  href="paperlist.jsp">        <b>查看电子报列表</b>        </a>    </body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -