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

📄 index.jsp

📁 智能文档检索系统
💻 JSP
字号:
<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8"import="java.sql.*" %><%@ page import="java.net.*"%><%@ page pageEncoding="UTF-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><jsp:useBean id="db_conn" scope="page" class="user.DB"/><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><style type="text/css" media="screen">			body {				font: 11px arial;			}			.suggest_link {				background-color: #FFFFFF;				padding: 2px 6px 2px 6px;			}			.suggest_link_over {				background-color: #E8F2FE;				padding: 2px 6px 2px 6px;			}			#search_suggest {				position: absolute; 				background-color: #FFFFFF; 				text-align: left; 				border: 1px solid #000000;						}				</style>                <title>智能文档检索</title><script language="javascript">   function check()    {       if(form1.txtSearch.value=="")       {         window.alert("检索信息不能为空!");         form1.txtSearch.focus();          form1.action="";       }    }                 //Gets the browser specific XmlHttpRequest Object                        function getXmlHttpRequestObject() {                                if (window.XMLHttpRequest) {                                        return new XMLHttpRequest();                                } else if(window.ActiveXObject) {                                        return new ActiveXObject("Microsoft.XMLHTTP");                                } else {                                        alert("Your Browser Sucks!\nIt's about time to upgrade don't you think?");                                }                        }                        function createAjaxObj(){                          var httprequest=false                          if (window.XMLHttpRequest)                          { // if Mozilla, Safari etc                            httprequest=new XMLHttpRequest()                            if (httprequest.overrideMimeType)                              httprequest.overrideMimeType('text/xml')                           }                           else if (window.ActiveXObject)                           { // if IE                             try {                               httprequest=new ActiveXObject("Msxml2.XMLHTTP");                             }                             catch (e){                               try{                                  httprequest=new ActiveXObject("Microsoft.XMLHTTP");                               }                               catch (e){}                             }                           }                           return httprequest                        }                        //Our XmlHttpRequest object to get the auto suggest                        var searchReq = createAjaxObj();                        //Called from keyup on the search textbox.                        //Starts the AJAX request.                        function searchSuggest() {                                if (searchReq.readyState == 4 || searchReq.readyState == 0) {                                        var str =document.getElementById('txtSearch').value;//escape(document.getElementById('txtSearch').value);                                                                               str=encodeURI(str);                                                                                                                                                               var url = "auto.jsp?search="+str;                                   		                        searchReq.open("GET", url, true);                                        searchReq.setRequestHeader( "Content-Type", "text/html;charset=UTF-8" );                                        searchReq.onreadystatechange = handleSearchSuggest;                                         searchReq.send(null);                                }		                        }                        //Called when the AJAX response is returned.                        function handleSearchSuggest() {                                if (searchReq.readyState == 4) {                                         var ss = document.getElementById('search_suggest');                                         var str = unescape(searchReq.responseText);                                                                                                                        ss.innerHTML="";                                                                                 var str = searchReq.responseText.split(",");                                         for(i=0; i < str.length - 1; i++) {                                                var suggest = '<div onmouseover="javascript:suggestOver(this);" ';                                                suggest += 'onmouseout="javascript:suggestOut(this);" ';                                                suggest += 'onclick="javascript:setSearch(this.innerHTML);" ';                                                suggest += 'class="suggest_link">' + str[i] + '</div>';                                                ss.innerHTML += suggest;                                        }                                }                        }                        //Mouse over function                        function suggestOver(div_value) {                                div_value.className = 'suggest_link_over';                        }                        //Mouse out function                        function suggestOut(div_value) {                                div_value.className = 'suggest_link';                        }                        //Click function                        function setSearch(value) {                                document.getElementById('txtSearch').value = value;                                document.getElementById('search_suggest').innerHTML = '';                        }</script><style type="text/css"><!--.STYLE1 {	font-family: "华文行楷";	font-size: 36px;	color: #FF0000;}--></style></head><body><%//登录部分Connection conn=db_conn.getConnection();Statement  denglu_stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);String userName=null;String userPwd=null;String user_ID=null;int userID=0;       Object ob_name=session.getAttribute("userName");//从会话中取得用户       Object ob_ID=session.getAttribute("userID");       if(ob_name!=null)       {          if(ob_ID!=null)           {                user_ID=ob_ID.toString();                userID=Integer.parseInt(user_ID);           }                   userName=ob_name.toString();         out.print(userName+"已登录");       }       if(userName==null)//用户还没有登录       {          if( request.getParameter("dl_userName")!=null && !request.getParameter("dl_userName").equals(""))            {	      userName =request.getParameter("dl_userName");	      userPwd = request.getParameter("dl_userPwd");              userName.trim();              userPwd.trim();       	      userName = new String(userName.getBytes("ISO8859-1"));	      userPwd = new String(userPwd.getBytes("ISO8859-1"));                     String check_user="select * from yonghu where userName='"+userName+"' and userPwd='"+userPwd+"'";              ResultSet check_user_rs=denglu_stmt.executeQuery(check_user);                            if(check_user_rs.next())//检查用户输入的用户名 和密码是否正确              {                  String Name=check_user_rs.getString("userName");                 String Pwd=check_user_rs.getString("userPwd");                 userID=check_user_rs.getInt("ID");                 Name.trim();                 Pwd.trim();                                   out.print(Name+"登录成功");                 session.setAttribute("userID",Integer.toString(userID));                 session.setAttribute("userName",userName);//写入会话              }            else             {                  out.print("用户名不正确!或密码不正确!或没有注册"+"<br>");                   }                          }        else//用户还没有登录         {%><form id="form2" name="form2" method="post" action="index.jsp">  <table width="761" border="0" class="user.css">    <tr>      <td width="81" align="right">用户名:</td>      <td width="171" align="left"><label>        <input name="dl_userName" type="text"  />      </label></td>      <td width="64" align="right">密码:</td>      <td width="186" align="left"><label>        <input name="dl_userPwd" type="password"  />      </label></td>      <td width="55" align="left"><label>        <input type="submit" name="Submit" value="登录" />      </label></td>      <td width="178" align="left"><label>如果您还没有注册请:<font size=5><a href="zhuce.jsp">注册</a></font></label></td>    </tr>  </table></form><%           }       }              ////登录部分结束 %><form name="form1" method="post" action="xianshi.jsp"><table width="90%" height="343" border="0" align="center">  <tr>    <td height="230" colspan="2"><div align="center">      <p class="STYLE1">&nbsp;</p>      <p class="STYLE1">&nbsp;</p>      <p class="STYLE1">&nbsp;</p>      <p class="STYLE1">智能文档检索</p>    </div></td>  </tr>  <tr>    <td width="68%" height="52">      <label>        <div  align="center" >                      <p>                <input type="text" id="txtSearch" name="txtSearch" alt="Search Criteria" onkeyup="searchSuggest();" autocomplete="off"  size="40" />            <input type="submit" id="cmdSearch" name="cmdSearch" value="Search" alt="Run Search"  onclick="check()"/><br /></p>        <div id="search_suggest" >        </div>                         </div>      </label>      <div align="justify"></div>        </td>    <td width="32%" rowspan="2">      <label></label>        </td>        <td height="53">      <label>                                                  </label>      <div align="justify"></div>    </td>  </tr></table><%Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);String topword[]=new String[10];int top_i=0;if(userName!=null){       //更改兴趣    String change_type_sql="update userlove set type=1 where userID="+userID+"and times>10 and type=0";    stmt.executeUpdate(change_type_sql);        //列出兴趣    String sql="select love from userlove where userID="+userID+" and type=1 order by times desc";    ResultSet rs=stmt.executeQuery(sql);    while(rs.next())     {                       String word=rs.getString("love");              word=word.trim();                            topword[top_i]=word;              top_i++;                              }    rs.close();    }if(top_i<10){    //列出搜索热门   String sql="select top 10 word from hotsearch order by times desc";   ResultSet rs=stmt.executeQuery(sql);   while(rs.next() && top_i<10)   {      String word=rs.getString("word");      word=word.trim();      int flag=0;               //用于检查topword[i]中是否有相同的值      for(int i=0;i<top_i;i++)      {          if(word.equalsIgnoreCase(topword[i]))            {                flag=1;   //等于1是有相同的值                        }               }      if(flag==0)//topword[i]中没有相同的值插入        {              topword[top_i]=word;              top_i++;         }    }   rs.close();}%><font size=4><table align="center">    <TR align="center"><TD>热门搜索TOP10:</TD></TR> </table></font>    <font size=4><table align="center">  <TR align="center"><div align="center"><%for(int i=0;i<5 && i<topword.length;i++){ String ww=java.net.URLEncoder.encode(topword[i],"UTF-8");%></div><TD width=100><p align="center"><a href="xianshi.jsp?text2=<%=ww%>"><%=topword[i]%></a></p></TD><%}%></TR><TR align="center"><div align="center"><%for(int i=5;i<10 && i<topword.length;i++){ String ww=java.net.URLEncoder.encode(topword[i],"UTF-8"); %><TD width=100><p align="center"><a href="xianshi.jsp?text2=<%=ww%>"><%=topword[i]%></a></p></TD><%}stmt.close();session.setAttribute("topword",topword); %></div></TR></table></font></form></body></html>

⌨️ 快捷键说明

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