分享
 
 
 

Oracle & JSP 开发的小型信息管理系统 (四) 源代码3

王朝java/jsp·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

//add.jsp 添加信息页面

<%

/*Cookie c[]=request.getCookies();

if(c==null)

{response.sendRedirect("login.jsp");}*/

String userName=(String)session.getAttribute("admin");

if(userName==null)

{response.sendRedirect("login.jsp");}

out.println("Welcome, "+userName);

request.setCharacterEncoding("big5");%>

<%@ page contentType="text/html;charset=big5"%>

<html>

<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"/>

<script language="javascript">

function f1_submit(){

if(document.f1.title.value=="")

{

alert("Sorry, 信息沒有輸入")

document.f1.title.focus()

return false

}

else if(document.f1.types.value=="")

{

alert("Sorry, 必需輸入信息類型!")

document.f1.types.focus()

return false

}

}

</script>

</head>

<style type="text/css">

<!--

.style2 {

color: #FFFFFF;

font-weight: bold;

}

.style3 {color: #FF0000}

.style5 {color: #0080C0}

-->

</style>

<form method="post" action="save.jsp" name="f1" LANGUAGE="javascript"

onsubmit="return f1_submit()" >

<table width="100%" border="1" cellspacing="1" cellpadding="1">

<tr bordercolor="#FFFFFF" bgcolor="#B5D85E">

<td height="24" colspan="2"><div align="center"><span class="style2">添 加 信 息</span></div></td>

</tr>

<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">

<td width="14%" height="24"><span class="style5">信息名稱</span></td>

<td width="86%"><input name="title" type="text" size="70"></td>

</tr>

<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">

<td height="23"><span class="style5">鏈接地址</span></td>

<td><input name="url" type="text" size="70"></td>

</tr>

<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">

<td height="28"><span class="style5">信息類型</span></td>

<td><select name="types">

<option value="mobile phone">mobile phone</option>

<option value="pc">pc</option>

<option value="mp3">mp3</option>

<option value="notebook">notebook</option>

</select></td>

</tr>

<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">

<td height="26"><span class="style5">信息說明</span></td>

<td><textarea name="content"></textarea></td>

</tr>

<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">

<td height="29"><span class="style5">信息大小</span></td>

<td><input name="big" type="text" size="10"></td>

</tr>

<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">

<td height="27"><span class="style5">信息評價</span></td>

<td><span class="style3">

<input name="vote" type="radio" value="1">★

<input name="vote" type="radio" value="2">

★★

<input name="vote" type="radio" value="3" checked>★★★<input name="vote" type="radio" value="4">

★★★★

<input name="vote" type="radio" value="5">

★★★★★</span></td>

</tr>

<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">

<td height="24"><span class="style5">相關主頁</span></td>

<td><input name="from1" type="text" size="64"></td>

</tr>

<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">

<td height="32"><span class="style5">相關地址</span></td>

<td><input name="form_url" type="text" size="64"></td>

</tr>

<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">

<td height="46" colspan="2"><div align="center">

<input name="Submit" type="submit" id="Submit" value="確認" class="buttonface"/>

&nbsp;&nbsp;&nbsp;

<input type="reset" name="Reset" value="取消" class="buttonface">

</div></td>

</tr>

</table>

</form>

</html>

//************************将添加的信息插入数据库:save.jsp

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

<%@ page import="moonsoft.test.j2ee.news.*"%>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=Big5">

<title>保存信息</title>

</head>

<body>

</body>

</html>

<%

String title1=request.getParameter("title");

String url1=request.getParameter("url");

String content1=request.getParameter("content");

String types1=request.getParameter("types");

//String hits1=request.getParameter("hits");

String big1=request.getParameter("big");

String vote1=request.getParameter("vote");

String from1=request.getParameter("from1");

String form_url1=request.getParameter("form_url");

String queryDBTime=" select to_char(systimestamp, 'YYYY-MM-DD HH24:MI:SS') from dual ";

//filter special Character

String types=FilterSpecial.filter(types1);

String url=FilterSpecial.filter(url1);

String content=FilterSpecial.filter(content1);

String big=FilterSpecial.filter(big1);

int vote=Integer.parseInt(vote1);

String from=FilterSpecial.filter(from1);

String form_url=FilterSpecial.filter(form_url1);

String title=FilterSpecial.filter(title1);

// decided the request contents

if(vote1==null)

{

out.println("<script language=javascript> alert('錯誤提示:為做評價!');javascript:history.back();</script>");

}

String time="2005-03-01 19:00:00";

boolean autoCommit=conn.getAutoCommit();

try{

PreparedStatement ps=conn.prepareStatement(queryDBTime);

ResultSet rs=ps.executeQuery();

while(rs.next())

{

time=rs.getString(1);

}

String insert=" insert into learning(article_id, types, title, url, content, big, vote, from1, form_url, date_and_time, hits) "+

" values(add_id_seq.NEXTVAL, '"+types+"', '"+title+"', '"+url+"', '"+content+"', '"+big+"', '"+vote+"', '"+from1+"', '"+form_url+"', '"+time+"', 1 ) " ;

out.println(insert);

ps=conn.prepareStatement(insert);

int rs1=ps.executeUpdate();

if(rs1>0)

{

%>

<head>

<link rel="stylesheet" href="css/article.css">

</head>

<div align="center">

<p>&nbsp;</p><table border="1" cellspacing="0" width="50%" bgcolor="#F0F8FF" bordercolorlight="#000000" bordercolordark="#FFFFFF" align="center">

<tr>

<td width="100%" bgcolor="#B5D85E" height="20">

<p align="center"><font color="#FFFFFF"><b>添加信息成功</b></font>

</td>

</tr>

<tr>

<td width="100%" height="177">

<table width="80%" border="0" cellspacing="0" cellpadding="2" align="center" bordercolorlight="#000000" bordercolordark="#FFFFFF">

<tr>

<td>信息名稱為:<font color="#FF0000"><%=title%></font></td>

</tr>

</table>

<p align="center">&nbsp;</p>

<p align="center"> <a href="add.jsp"> 繼續添加數據</a>&nbsp;&nbsp; <a href="manage.jsp">返回管理頁面</a><br>

</p>

</td>

</tr>

</table>

</div>

<%conn.commit();}}

catch(SQLException se1)

{se1.printStackTrace();

conn.rollback();}

finally{

conn.setAutoCommit(autoCommit);

conn.close(); }

%>

//*******************************显示信息页面:通过javascript 在index.jsp里弹出的窗口:view.jsp

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

<%

String id1=request.getParameter("id").trim();

int id=Integer.parseInt(id1);

String queryInfo=" select * from learning where article_id='"+id+"' ";

String updateHits=" update learning set hits=hits+1 where article_id='"+id+"' ";

boolean autoCommit=conn.getAutoCommit();

%>

<html>

<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>

<style type="text/css">

<!--

.style2 {

color: #FFFFFF;

font-weight: bold;

}

.style3 {color: #FF0000}

.style5 {color: #0080C0}

-->

</style>

<form method="post" action="saveEdit.jsp" ><%

try{

conn.setAutoCommit(false);

PreparedStatement ps=conn.prepareStatement(updateHits);

int results=ps.executeUpdate();

if(results>0)

{out.println();}

conn.commit();

ps=conn.prepareStatement(queryInfo);

ResultSet rs=ps.executeQuery();

while(rs.next()){

%>

<table width="100%" border="1" cellspacing="1" cellpadding="1">

<tr bordercolor="#FFFFFF" bgcolor="#B5D85E">

<td height="24" colspan="2"><div align="center"><span class="style2">查 看 信 息</span></div></td>

</tr>

<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">

<td width="14%" height="24"><span class="style5">信息名稱</span></td>

<td width="86%"><%=rs.getString("title")%></td>

</tr>

<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">

<td height="23"><span class="style5">鏈接地址</span></td>

<td><%=rs.getString("url")%></td>

</tr>

<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">

<td height="28"><span class="style5">信息類型</span></td>

<td><%=rs.getString("types")%></td>

</tr>

<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">

<td height="26"><span class="style5">信息說明</span></td>

<td><%=rs.getString("content")%></td>

</tr>

<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">

<td height="29"><span class="style5">信息大小</span></td>

<td><%=rs.getString("big")%></td>

</tr>

<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">

<td height="27"><span class="style5">信息評價</span></td>

<td><%

String temp=rs.getString("vote");

//out.println(temp);

int tempVotes=Integer.parseInt(temp);

for(int i=0; i<tempVotes; i++){%><font color="red">★</font><%}

%>

</tr>

<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">

<td height="24"><span class="style5">相關主頁</span></td>

<td><%=rs.getString("from1")%></td>

</tr>

<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">

<td height="32"><span class="style5">相關地址</span></td>

<td><%=rs.getString("form_url")%></td>

</tr>

<tr>

</tr>

</table>

ID:<%=rs.getString("article_id")%>&nbsp;

點繫次數:<%=rs.getString("hits")%>&nbsp;

創建時間:<%=rs.getString("date_and_time")%>&nbsp;

<%

}}

catch(SQLException se1)

{se1.printStackTrace(); conn.rollback();}

catch(NumberFormatException n1)

{n1.printStackTrace();

throw n1;

}

finally{

conn.setAutoCommit(autoCommit);

conn.close();

}

%>

<br><center>

<!--input type="submit" value="確認" class="buttonface"/>&nbsp;-->

</center>

</form>

</html>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有