lx.jsp

来自「--- --^_^-------------- 广师公寓中心 1.请装上」· JSP 代码 · 共 266 行

JSP
266
字号
<%@ page contentType="text/html; charset=gb2312" %>
<%@ page language="java" import="java.sql.*" %>
<%
int counter=0;
Cookie cookies[]=request.getCookies();
if(cookies!=null){
   for(int i=0;i<cookies.length;i++){
       if(cookies[i].getName().equals("counter"))
	       counter=Integer.parseInt(cookies[i].getValue());
		  }
}
%> 
<html>
<head>
<title>信息反馈</title>
<style type="text/css">
<!--
table {
	font-family: "宋体";
	font-size: 14px;
	color: #000000;
}
.style1 {font-family: "宋体"}
.unn {
	vertical-align: text-top;
}
.amed1 {
	border: thin dashed #006600;
}
.unnamed2 {	border-top-width: thin;
	border-bottom-width: thin;
	border-top-style: dashed;
	border-bottom-style: dashed;
	border-top-color: #333333;
	border-bottom-color: #333333;
}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<SCRIPT LANGUAGE=JavaScript>
<!-- Begin
if (window.print) {
document.write('<form>'
+ '<input type=button name=print value=打印 '
+ 'onClick=javascript:window.print()></form>');
}
// End -->
</script>
<!-- ImageReady Slices (glry.psd) -->
<center>
  <table id="__01" width="680" height="425" border="0" cellpadding="0" cellspacing="0">
    <!--DWLayoutTable-->
	  <tr>
		  <td colspan="6">
			  <img src="images/glry_01.gif" width="680" height="55" alt=""></td>
	  </tr>
	  <tr>
		  <td colspan="6">
			  <img src="images/glry_02.gif" width="680" height="46" alt=""></td>
	  </tr>
	  <tr>
		  <td colspan="6">
			  <img src="images/glry_03.gif" width="680" height="41" alt=""></td>
	  </tr>
	  <tr>
		  <td colspan="6" background="images/glry_04.gif" height="20">
<font color="#FF0000" size="2">
<jsp:include page="time.htm"/>
<%
    if(counter==0){
 //if(session.getAttribute("counter1") == null){
    out.print("欢迎首次光临!");
	}
else{
    out.print("今天您已经光临了"+counter+"次!");
	//out.print("您已经光临了"+session.getAttribute("counter1")+"次!");
    }
%>
</font>
	    </td>
	  </tr>
	  <tr>
		  <td width="115">
			  <a href="gongyu.jsp"><img src="images/glry_05.gif" alt="" width="115" height="19" border="0"></a></td>
		  <td width="113">
			  <a href="ry.jsp"><img src="images/glry_06.gif" alt="" width="113" height="19" border="0"></a></td>
		  <td width="112">
			  <a href="xszs.jsp"><img src="images/glry_07.gif" alt="" width="112" height="19" border="0"></a></td>
		  <td width="113">
			  <a href="wh.jsp"><img src="images/glry_08.gif" alt="" width="113" height="19" border="0"></a></td>
		  <td width="113">
			  <a href="lx.jsp"><img src="images/glry_09.gif" alt="" width="113" height="19" border="0"></a></td>
		  <td width="114">
			  <a href="hd.jsp"><img src="images/glry_10.gif" alt="" width="114" height="19" border="0"></a></td>
	  </tr>
	  <tr>
	    <td height="154" colspan="6" valign="top" background="images/glry_11.gif">			  
	      <table width="100%" border="0" cellpadding="0" cellspacing="0">
		    <!--DWLayoutTable-->
		    <tr>
		      <td width="680" height="25" valign="top"><a href="gongyu.jsp">首页</a>>><span class="unnamed2">信息反馈</span></td>
	        </tr>
		    <tr>
		      <td height="129" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
		        <!--DWLayoutTable-->
		        <tr>
		          <td width="680" height="17" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
	            </tr>
		        <tr>
		          <td height="112" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
		              <!--DWLayoutTable-->
		              <tr>
		                <td height="42" colspan="3" valign="top"><div align="center" class="style1"><font size="+4">留言
  
</font></div></td>
	                  </tr>
					  
		              <tr>
		                <td width="103" height="70">&nbsp;</td>
		                <td width="475" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<%
try{  
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e)
{  
out.print(e);
}
try{  
String strDirPath=application.getRealPath(request.getRequestURI());   
strDirPath=strDirPath.substring(0,strDirPath.lastIndexOf('\\'))+"\\";  
strDirPath=application.getRealPath("ODBC/gongyu.mdb");  
String url = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ="+strDirPath; 
Connection conn = DriverManager.getConnection(url);  
Statement stmt = conn.createStatement();
String sql="SELECT * FROM liuyan";
ResultSet rs = stmt.executeQuery(sql); 
request.setCharacterEncoding("gb2312"); 
String word="";
String name="";
String shi="";
while(rs.next()){
word=rs.getString("word");
name=rs.getString("name");
shi=rs.getString("shijian");
%>				  
<%!
//下面是将空格换为<br>
StringBuffer mytranslate(StringBuffer sour){
  for(int i=0;i<sour.length();i++){
     if(sour.substring(i,i+1).equals("\n")){
		  	sour.delete(i,i+1);
			sour.insert(i,"<br>");
		}
	}
	return sour;
}
%>
<%
StringBuffer message1 = new StringBuffer(word);
message1 = mytranslate(message1);
%>	                       
						    <!--DWLayoutTable-->
	                        <tr>
	                          <td width="475" height="31" valign="top"><br><div align="left"><%=shi%>&nbsp;&nbsp;by:<%=name%></div></td>
                            </tr>
	                        <tr>
	                          <td height="39" valign="top"><div align="center"><%=message1%></div><br><hr></td>
                            </tr>

<%}  
rs.close();  
stmt.close();  
conn.close();
}
catch(Exception ex)
{  
out.print(ex);
}
%>							
                           </table>
					    </td>
		                <td width="102">&nbsp;</td>
		              </tr>

                  </table></td>
	            </tr>
	                                      </table></td>
	        </tr>
          </table></td>
	  </tr>
	  <tr>
	    <td height="138" colspan="6" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" background="images/glry_11.gif">
	      <!--DWLayoutTable-->
	      <tr>
	        <td width="680" height="138" valign="top">
			<!--  我的留言:结束  -->
            <script language=javascript>
                function MyCheck()
                {	                		
                    var Content = MessageForm.TxtContent.value;
					var Content1 = MessageForm.MbName.value;
					
                    if(Content==null||Content==""||Content.indexOf("留言内容不能超过500字")>=0)
                    {
                        alert("留言内容不能为空!");
	                    MessageForm.TxtContent.focus();
	                    MessageForm.TxtContent.value="";
	                    return false;
                    }
                    if( Content.indexOf("<") >=0 || Content.indexOf(">") >=0 )
                    {
	                    alert("留言内容含有非法字符!");
	                    return false;
                    }
                    if(Content1==null||Content1=="")
                    {
                        alert("用户名不能为空!");
	                    MessageForm.MbName.focus();
	                    MessageForm.MbName.value="";
	                    return false;
                    }
                    if( Content1.indexOf("<") >=0 || Content1.indexOf(">") >=0 )
                    {
	                    alert("用户名含有非法字符!");
	                    return false;
                    }                    
                    if( TxtContent.value.length > 500 )
                    {
                        alert("留言内容超过500字");
	                    return false;
                    }
            		
                    return true;
                }
            </script>
            <!-- 【我也要留言:开始】 -->
			<div align="center">
            <form name="MessageForm" id="MessageForm"  method="post" action ="lx1.jsp" onsubmit="return MyCheck();">       
                  <div align="center">大名:<input name="MbName" type="text" id="MbName" value="游客" size="52">
                  </div>
                     <div align="left">            (请填写上你的大名)
                                   
                     </div>
                     <div>内容:<textarea name="TxtContent" cols="50" rows="6"  class="unn" id ="TxtContent" style="color:#666666" onfocus="if( this.value=='留言内容不能超过500字') {this.value='';}">留言内容不能超过500字</textarea>
                     </div>
                        <input id="MbSubmit" class="release_2_sub" name="submit" type="submit" value="提交">   
                        <input name="MbCancel" id="MbCancel" type="reset" value="取消">
            </form>
			</div>
            <!-- 【我也要留言:结束】 -->  
			</td>
          </tr>
        </table></td>
    </tr>
	  <tr>
	    <td height="48" colspan="6" valign="top">
	      <img src="images/glry_12.gif" width="680" height="48" alt=""></td>
	  </tr>
  </table>
  <!-- End ImageReady Slices -->
</center>
</body>
</html>

⌨️ 快捷键说明

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