zoukankan      html  css  js  c++  java
  • jsp第8个作业

    public boolean addMail(Msg msg){
            Statement st =null;
            Connection con=null;
            try{
                //获取连接
                con = getConnection();
                //书写SQL语句
                st = con.createStatement();
                java.util.Date msg_crate_date = msg.getMsg_create_date();
                String sqlmsg_create_date = String.format("%tF", msg_crate_date);
                String sql = "insert into msg(username,title,msgcontent,state,sendto,msg_create_date) "+"values('"+msg.getUsernname()+"','"
                +msg.getTitle()+"','"
                +msg.getMsgcontent()+"','"
                +msg.getState()+"','"
                +msg.getSendto()+"','"
                +sqlmsg_create_date+"'"
                +")";
                int row = st.executeUpdate(sql);
                if(row>0){
                    //发送成功
                    return true;
                }
                
            }catch(SQLException e){
                e.printStackTrace();
            }finally{
                closeAll(con, st, null);
            }
            return false;
        }
    

      

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <base href="<%=basePath%>">
        
        <title>My JSP 'write.jsp' starting page</title>
        
        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">    
        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="This is my page">
        <!--
        <link rel="stylesheet" type="text/css" href="styles.css">
        -->
    
      </head>
      
      <body>
     
            <form action="" method="post">
            发件人:<input type="text" name="sjr" value="ls"  readonly="readonly"/><br/>
            标    题:<input type="text" name="bt" />     <br/>
            正    文:<br/>
            <textarea rows="10" cols="30" name="zw"></textarea> <br/>
            <input type="submit" value="发送" />
            <a href="main.jsp">返回</a>
        </form>
      </body>
    </html>

     

     

     

  • 相关阅读:
    基于ADO的远程Oracle连接
    oracle中的定时任务
    关于C++ const 变量
    堆排序和选择排序
    插入排序
    多线程的两种启动方式
    多尺度变换去噪的阈值选择
    jstree
    JS中call、apply、bind使用指南,带部分原理。
    六. JavaScript时间日期格式化
  • 原文地址:https://www.cnblogs.com/Suzy-an/p/12870992.html
Copyright © 2011-2022 走看看