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

📄 do_tougao2.jsp

📁 jsp实现的在线投稿系统,简单的界面!数据库设计
💻 JSP
字号:
<%@ page contentType="text/html; charset=GBK" %>
<%@ page session="true"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.util.Date"%>
<%@ page language="java" import="com.jspsmart.upload.*"%>
<jsp:useBean id="SmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" />
<jsp:useBean id="db" scope="page" class="lianjie.DataBase"/>
<%
  int count = 0;
  String ct="";
  SmartUpload su = new SmartUpload();
  su.initialize(pageContext);
  su.setAllowedFilesList("doc,txt,pdf");
  try{
    su.setDeniedFilesList("exe,bat,jsp,htm,html");
    su.upload();
    count = su.save("/upload");
  }catch(Exception ee){out.print("上传文件失败!");}
  ct=count+"";
  System.out.println( count+" files   upload   success.");
  com.jspsmart.upload.File file = su.getFiles().getFile(0);
  String path=file.getFilePathName();
  System.out.println(path);
  %>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>在线投稿系统</title>
<style type="text/css">
<!--
.STYLE1 {
	font-family: "幼圆";
	font-size: 24px;
	color: #CC00CC;
}
-->
</style>
</head>
<body background="images/bj.gif">
<table width="762" border="0" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td width="92" height="137">&nbsp;</td>
    <td colspan="3" valign="top"><img src="images/logo.gif" width="667" height="137" alt=""></td>
  </tr>
  <tr>
    <td height="34">&nbsp;</td>
    <td colspan="3" valign="top"><div align="right"><a href="notice.html">投稿须知</a></div></td>
  </tr>
  <tr>
    <td height="47">&nbsp;</td>
    <td width="163">&nbsp;</td>
    <td width="316">&nbsp;</td>
    <td width="191">&nbsp;</td>
  </tr>
  <tr>
    <td height="156">&nbsp;</td>
    <td>&nbsp;</td>
    <td valign="top"><p>&nbsp;</p>
    <%int workId=0;
      int userId=0;
      int majorId=-1;
      String title=(String)session.getAttribute("title");
      String penname=(String)session.getAttribute("penname");
      String summary=(String)session.getAttribute("summary");
      String keywords=(String)session.getAttribute("keywords");
      String Id = (String) session.getAttribute("userId");

      if (Id == null||Id.equals(""))
      {  response.sendRedirect("Logon1.jsp");}
      else{
          userId=Integer.parseInt(Id);
      }

      String str = "select majorId from usertable where userID like " + userId;
      ResultSet rs = null;
      rs =db.executeQuery(str);
      try{
           while(rs.next())
             {
                majorId=rs.getInt("majorID");
             }
        }catch(Exception e){out.print("数据库出错1!");}

      java.util.Date m_date=new Date();
      String condate=m_date.toLocaleString();

      try{
        String str1="insert into judge(userID,title,majorID,condate,state,idea,penname,abstract,keywords,content)values(";
        str1=str1+userId+",'"+title+"',"+majorId+",'"+condate+"',"+0+",'无','"+penname+"','"+summary+"','"+keywords+"','"+path+"');";
        ResultSet rs1=db.executeQuery(str1);
      }catch(Exception e2){out.print("数据库出错2!");}

      String str2="select worksID from judge where userID ="+userId+" and title like '"+title+"' and condate like '"+condate+"';";
      ResultSet rs2 = null;
      rs2 =db.executeQuery(str2);

      try{
        while(rs2.next()){
           workId=rs2.getInt("worksID");
	  System.out.println(workId);
	}}catch(Exception e3){out.print("数据库出错3!");}

      if(ct=="0"||ct.equals("0")){
	%>
    <p align="center" class="STYLE1"><strong>没有上传文件,请重新投稿!</strong></p>
    <p align="center" class="STYLE1"><a href="tougao.jsp">返回 重新投稿</a></p></td>
	<%}else{%>
    <p align="center" class="STYLE1"><strong>您的作品号为<%=workId%>号:</strong></p>
    <p align="center" class="STYLE1"><strong>文件上传成功!</strong></p>
    <p align="center" class="STYLE1"><strong>投 稿 成 功 !</strong></p><td>&nbsp;</td>
	<%}%>
  </tr>
  <tr>
    <td height="146">&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
</body>
</html>

⌨️ 快捷键说明

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