Oracle & JSP 开发的小型信息管理系统 (二) 源代码1_sylmoon的博客-程序员宅基地

技术标签: stylesheet  div  input  oracle  string  programming.diary  jsp  

**************************************//index .jsp 默认登录,查看信息页面

<%@ include file="articleconn1.jsp"%>
<%

 %>
<html>
<head>

<title>信息查詢系統</title>

<script>
 

function openwin(id){  window.open("view.jsp?id="+id,"","height=450,width=550,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");}

</script>
<link rel="stylesheet" href="css/style.css">
</head>

<body bgcolor="#FFFFFF" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
<table width="609" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td>
      <div align="center"><img src="images/TITLE.jpg" width="587" height="174"></div>
    </td>
  </tr>
</table>
<div align="center"></div>
<table width="607" cellpadding="0" cellspacing="0" align="center">
  <tr>
    <td colspan="3" height="117">
      <table border="1" width="100%" bordercolorlight="#000000" bordercolordark="#FFFFFF" cellpadding="0" cellspacing="0" align="center">
        <tr>
          <td height="16" bgcolor="#B5D85E" width="81%">
            <div align="center">
   

              <p><font color="#000000"><strong>信 息 列 表</strong></font>
              </p>
            </div>
          </td>
        </tr>
        <tr>
          <td width="81%" align="center" valign="top" height="139">
            <div align="center">

              <div align="center">
                <div align="center"><br>
                  <br>
                  <div align="center">
                    <p align="left">
                      <%
int intPageSize;
int intRowCount;//記錄總數
int intPageCount;//總頁數
int intPage;//頁面參數
String strPage;//定義變數用來傳遞page
int i,j;
intPageSize=5;//定義每頁顯示5條記錄
strPage=request.getParameter("page");//取得當前的頁碼
if(strPage==null){//判斷初始頁面,如果沒有顯示記錄,就置為第一頁
intPage=1;
}else{
intPage=Integer.parseInt(strPage);//將strPage轉化為整數
if(intPage<1) intPage=1;
}

String sqlname="select count(article_id) from learning ";

 //sqlname="select count(article_id) from learning where title like '%"+keyword+"%'  and types like '%"+typename+"%' order by article_id desc";

PreparedStatement ps=conn.prepareStatement(sqlname);
ResultSet rs1=ps.executeQuery();
rs1.next();
intRowCount=rs1.getInt(1);//取得整數保存與intRowCount變數中
intPageCount=(intRowCount+intPageSize-1)/intPageSize;//計算出總頁數(記錄總數+每頁顯示的記錄-1)/每頁顯示的記錄)
if(intPage>intPageCount)
intPage=intPageCount;

String query=" select * from learning order by article_id ";

ResultSet rs=ps.executeQuery(query);//執行sql,按照時間先後排序顯示
i=(intPage-1)*intPageSize;
for(j=0;j<i;j++)
rs.next();
%>
<%-- 設置intPage參數 --%>
   <FORM action=index.jsp method=POST>
<p align='center' vAlign='bottom'>
    第<%=intPage%>頁 &nbsp;&nbsp;&nbsp;共<%=intPageCount%>頁&nbsp;&nbsp;&nbsp;
    <%if(intPage<intPageCount){%>
    <a href="index.jsp?page=<%=intPage+1%>">下一頁</a>&nbsp;&nbsp;&nbsp;
    <%}%>
    <%if(intPage>1){%>
    <a href="index.jsp?page=<%=intPage-1%>">上一頁</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <%}%>
     </form>
                     
                  </div>
                  <div align="center">
                    <center>
                      <table border="1" cellspacing="0" width="90%"
    bgcolor="#F0F8FF" bordercolorlight="#000000" bordercolordark="#FFFFFF" background="../images/top-linebg.gif">
                        <tr>
                          <td width="15%" align="center" height="20" bgcolor="#B5D85E"><font color="#000000">ID
                            號 </font></td>
                          <td width="45%" align="center" bgcolor="#B5D85E"><font color="#000000">信
                            息 名 稱</font></td>
                          <td width="26%" align="center" bgcolor="#B5D85E"><font color="#000000">上
                            載 時 間</font></td>
                          <td width="15%" align="center" bgcolor="#B5D85E"><font color="#000000">點
                            擊</font></td>
                        </tr>
                          <%if(intRowCount==0){%>
    對不起,還沒有資料!
    <%}else{%>
  <%-- 顯示每頁的資料 (根據i的值判斷每頁的5條記錄) --%>
 <%
  i=0;
  while(i<intPageSize && rs.next()){
 %>
                        <tr>
                          <td width="15%" height="23" bgcolor="#FFFFFF">
                            <p align="center"><%=rs.getString("article_id")%>
                          </td>
                          <td width="45%" bgcolor="#FFFFFF">
                             <a href="javascript:openwin(<%=rs.getString("article_id")%>)" title="<%=rs.getString("title")%>"><%=rs.getString("title")%></a>
                                               
                          </td>
                          <td width="26%" bgcolor="#FFFFFF">
                            <div align="center"><%=rs.getString("date_and_time")%></div>
                          </td>
                          <td width="15%" bgcolor="#FFFFFF">
                            <p align="center"><%=rs.getString("hits")%>
                          </td>
                        </tr>
          <%
   i++;//通過I迴圈設置每頁的頁數
    }
 %>
  
   
  <%}%>
                      </table>
                    </center>
                  </div>
               <FORM action=index.jsp method=POST>
<p align='center' vAlign='bottom'>
    第<%=intPage%>頁 &nbsp;&nbsp;&nbsp;共<%=intPageCount%>頁&nbsp;&nbsp;&nbsp;
    <%if(intPage<intPageCount){%>
    <a href="index.jsp?page=<%=intPage+1%>">下一頁</a>&nbsp;&nbsp;&nbsp;
    <%}%>
    <%if(intPage>1){%>
    <a href="index.jsp?page=<%=intPage-1%>">上一頁</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <%}%>
        <br>到第<input type="text" name="page" size="5" value="1"/>頁
        <input type="submit" value="確定" class="buttonface">
     </form>
         <%
     
         String userName=(String)session.getAttribute("admin");
         if(userName==null){userName="";}
         if(userName.equals("admin")){
        
         %>
         &nbsp; &nbsp;<a href="manage.jsp">系統管理</a><%}
         else{%>
         &nbsp; &nbsp;<a href="login.jsp">登錄系統管理</a><%}%>
        
                </div>
              </div>
            </div>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<%rs.close();

conn.close();
%>
<p align="center">Copyright &copy;moonsoft 2004</p>
</body>
</html>

****************************************//login.jsp 登录页面

<%@ page contentType="text/html;charset=big5"%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<title>信息查詢系統</title>
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<link rel="stylesheet" href="css/style.css">
</head>
           
<body bgcolor="#FFFFFF">
<div align="center"><br>
  <font color="#000000">管理系統</font> <br>
</div>
            <form method="post" action="chklogin.jsp">
  <div align="center">
    <p> 用戶名稱
      <input class=TextBorder maxlength=25  
            name=username size=13 value="">
    </p>
    <p> 管理密碼
      <input class=TextBorder maxlength=25  
            name=password size=13 type="password" value="">
    </p>
    <p>
      <input type="submit" value="确定" name="cmdOk" class="buttonface">
      &nbsp;
      <input type="reset" value="重填" name="cmdReset" class="buttonface">
      &nbsp; </p>
  </div>
</form>
<div align="center">
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
</div>
</body>

************************//chklogin验证登录页面,如果正确,sendRedirect 到manage.jsp

<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=big5">
    <title>chklogin</title>
  </head>
 
  <%!String userName, password, adminvalue;%>
  <%
  adminvalue="admin";
  request.setCharacterEncoding("big5");
  userName=request.getParameter("username").trim();
  password=request.getParameter("password").trim();
  if(userName==null)
  {response.sendRedirect("index.jsp");}
  if(password==null)
  {response.sendRedirect("index.jsp");}
  if(userName.equals(adminvalue)&&password.equals(adminvalue))
  {
  /*Cookie theadminok=new Cookie("adminok", "true");
  response.addCookie(theadminok);
  response.sendRedirect("manage.jsp");*/
  HttpSession se=request.getSession();
  se.setAttribute("admin",userName);
  response.sendRedirect("manage.jsp");
  }
  else{response.sendRedirect("index.jsp");}
  %>
  <body>
 
  </body>
</html>

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/sylmoon/article/details/330540

智能推荐

女孩子的试炼html5魔塔_u010001356的博客-程序员宅基地

女孩子的试炼攻略:#include&lt;cstdio&gt;#include"windows.h"int hp0=515,atk1=10,dex1=10;int monstercount=19;int bounscount=33;int allmonster=7;struct enemys{ short hp,atk,dex,spj;//0都没有1魔攻2兼顾3先攻4二连击}enemy[7];short allstatus[524288]={};//对应状态最大hpchar atk0[

BatchNormalization、LayerNormalization、InstanceNorm、GroupNorm、SwitchableNorm总结_夏洛的网的博客-程序员宅基地

本篇博客总结几种归一化办法,并给出相应计算公式和代码。1、综述1.1 论文链接1、Batch Normalizationhttps://arxiv.org/pdf/1502.03167.pdf2、Layer Normalizaitonhttps://arxiv.org/pdf/1607.06450v1.pdf3、Instance Normalizationh...

怎么分析服务器的性能,分析服务器性能_索多姆卡军械库的博客-程序员宅基地

磁盘:sar -d [interval] [count][[email protected] ~]$ sar -d 1 3Linux 3.10.0-957.27.2.el7.x86_64 (k8s-master01) 01/10/2020 _x86_64_ (4 CPU)05:25:51 PM DEV tps rd_sec/s wr_sec/...

Linux ubuntu JDK安装方法_Androidfoolish的博客-程序员宅基地

JDK安装方法很简单,请参考以下步骤~JDK下载地址:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html我使用的是:jdk-8u201-linux-x64.tar.gz下载后安装命令: sudo mkdir /usr/lib/jvm sudo...

mac tomcat8 虚拟目录配置_tomcat8 默认虚拟目录_哈灰色的博客-程序员宅基地

属性说明:crossContext  如果想在应用内调用ServletContext.getContext()来返回在该虚拟主机上运行的其他web application的request dispatcher,设为true。在安全性很重要的环境中,设为false,使得getContext()总是返回null。缺省值为false。docBase         该web应用的文档基准目录(D

(转)Spark(六)Spark之开发调优以及资源调优_RayBreslin的博客-程序员宅基地

【转载原因:大神太厉害了,调优思路受益匪浅!】【转载原文:https://www.cnblogs.com/frankdeng/p/9301780.html】Spark调优主要分为开发调优、资源调优、数据倾斜调优、shuffle调优几个部分。开发调优和资源调优是所有Spark作业都需要注意和遵循的一些基本原则,是高性能Spark作业的基础;数据倾斜调优,主要讲解了一套完整的用来解决Spark...

随便推点

json操作_json中seek(0)_小白头一号的博客-程序员宅基地

字典与json 互转# json 就是一个字符串d = { "username": "xiaoming", "password":"123456啊"}import jsonwith open('userjson.txt', 'w', encoding='utf-8') as f: # 把字典转成json字符串, # ensure_ascii=False:...

Centos 6.7 LNMP环境下整合安装zabbix2.4_lnmp环境下yum安装zabbix_Mr_老Zhang的博客-程序员宅基地

写在最前面:此文也是给自己学习做一个记录,也参照了各种大神前辈的文章,才得此顺利搭建完成。文章1、文章2、文章31、唠叨几句lnmp环境的安装:正所谓是一波三折,lnmp这个大家都不用说网上也有各种一键安装(可参照极其出名的此网站)。当初想着的是对nginx 、mysql、php啥的各种源码编译安装,可是很费劲的是lnmp环境倒是ok了,但是要是跑zabbix就是跑

2013 Multi-University Training Contest 7_Bright-xl的博客-程序员宅基地

1001 Hyperspace求最远曼哈顿距离,求曼哈顿距离并不难,难的是这题需要求n次,而且其中有删点,k维空间。。。虽然比赛时没有AC,但也想到了枚举2^k种情况+-得到最远曼哈顿距离的方法,可是由于没想到用stl里的set,multiset,map等处理删点问题,导致复杂度一直为O(n^2*k*2^k)之后看了标程才知道了原来可以去掉n次。#include#include

基于社交媒体的政治情感分析的相关论文_庞加莱的博客-程序员宅基地

2010Tumasjan, Andranik, et al. "Predicting elections with twitter: What 140 characters reveal about political sentiment."Fourth international AAAI conference on weblogs and social media. 2010.被引...

18:LAMP环境-下_龙跃丶的博客-程序员宅基地

LAMP环境-下LAMP环境-下配置防盗链配置方式测试效果访问控制Directory配置方式测试效果访问控制FilesMatch配置方式测试效果限定某个目录禁止解析php配置方式测试效果限制user_agent配置方式测试效果php相关配置php扩展模块装安配置防盗链 首先来了解一下什么是盗链,全称是盗取链接...

简单密码破解_码莎拉蒂 .的博客-程序员宅基地

描述:密码是我们生活中非常重要的东东,我们的那么一点不能说的秘密就全靠它了。哇哈哈. 接下来渊子要在密码之上再加一套密码,虽然简单但也安全。假设渊子原来一个BBS上的密码为zvbo9441987,为了方便记忆,他通过一种算法把这个密码变换成YUANzhi1987,这个密码是他的名字和出生年份,怎么忘都忘不了,而且可以明目张胆地放在显眼的地方而不被别人知道真正的密码。他是这

推荐文章

热门文章

相关标签