?? search.jsp
字號:
<%@ page language="java" import="java.sql.*,java.util.* " %>
<HTML>
<HEAD>
<TITLE>Search Our Site</TITLE>
<LINK href="newstyle.css" type=text/css
rel=stylesheet>
</head>
<BODY bgColor=#862b13 leftMargin=0 topMargin=0 MARGINHEIGHT="0" MARGINWIDTH="0">
<TABLE cellSpacing=1 cellPadding=0 width=776 align=center bgColor=#ff9900
border=0 height="438">
<TBODY>
<TR>
<TD height="436">
<TABLE cellSpacing=0 cellPadding=0 width=776 border=0>
<TBODY>
<TR>
<TD bgcolor="#FFFFFF" bordercolor="#FFFFFF" background="">
<p align="center"> </p>
<p align="left" style="margin-top: 0; margin-bottom: 0">
</p>
<p align="center"><b><font size="5" face="Bookman Old Style">
<font color="#862B13">Search Results</font>
<%
String delims=" ";
String tempString="";
Connection con=null;
Connection con1=null;
Connection con2=null;
Connection con3=null;
Statement stmt=null;
Statement stmtAnother;
ResultSet rs=null;
Statement stmt1=null;
ResultSet rsAnother=null;
String value="";
StringTokenizer tok;
Vector v=new Vector();
Vector urlname=new Vector();
value=request.getParameter("T1");
if(value!=null)
{
tok=new StringTokenizer(value,delims);
while(tok.hasMoreTokens())
{
String s1=tok.nextToken();
//if(tab.avoidToken(s1)==false)
//{
v.addElement(s1);
//}
}
for(int i=0;i<v.size();i++)
{
tempString=(v.elementAt(i)).toString();
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:search","","");
Statement st=con.createStatement();
ResultSet result=st.executeQuery("select URLADDRESS,FREQUENCY from INDEXTABLE where KEYWORD like'"+tempString+"%'");
if(result!=null)
{
while(result.next())
{
String urlAddress=result.getString("URLADDRESS");
int frequency=Integer.parseInt(result.getString("FREQUENCY"));
try{
stmtAnother=con.createStatement();
rsAnother=stmtAnother.executeQuery("select URLADDRESS from RESULT "+"where URLADDRESS='"+urlAddress+"'");
if(rsAnother.next())
{
try{
stmt1=con.createStatement();
stmt1.executeUpdate("update RESULT"+" set SUMFREQ=SUMFREQ+"+frequency+" where URLADDRESS='"+urlAddress+"'");
stmt1.close();
}catch(Exception wd){System.out.println("2"+wd);}
}
else
{
try{
stmt1=con.createStatement();
stmt1.executeUpdate("insert into RESULT"+" values('"+urlAddress+"',"+frequency+")");
stmt1.close();
}catch(Exception we){System.out.println("3"+we);}
}
stmtAnother.close();
}catch(Exception wc){System.out.println("4"+wc);}
}
}
st.close();
con.close();
}catch(Exception wb){System.out.println("5"+wb);}
}
//}
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:search","","");
}catch(Exception ws1){System.out.println("6"+ws1);}
stmt=con.createStatement();
rs=stmt.executeQuery("select URLADDRESS from RESULT order by SUMFREQ desc");
%>
</font><font face="Bookman Old Style">
</font><font size="5" face="Bookman Old Style">
<ul style="color: #862B13; font-size: 12pt" type="square">
<%
int size=0;
if(rs!=null)
{
while(rs.next())
{
urlname.addElement(rs.getString("URLADDRESS"));
size++;
}
//v=null;
stmt.executeUpdate("delete from RESULT");
stmt.close();
}
//////////////////////////
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con1=DriverManager.getConnection("jdbc:odbc:search1","","");
Statement st=con1.createStatement();
ResultSet result=st.executeQuery("select URLADDRESS,FREQUENCY from INDEXTABLE where KEYWORD like'"+tempString+"%'");
if(result!=null)
{
while(result.next())
{
String urlAddress=result.getString("URLADDRESS");
int frequency=Integer.parseInt(result.getString("FREQUENCY"));
try{
stmtAnother=con1.createStatement();
rsAnother=stmtAnother.executeQuery("select URLADDRESS from RESULT "+"where URLADDRESS='"+urlAddress+"'");
if(rsAnother.next())
{
try{
stmt1=con1.createStatement();
stmt1.executeUpdate("update RESULT"+" set SUMFREQ=SUMFREQ+"+frequency+" where URLADDRESS='"+urlAddress+"'");
stmt1.close();
}catch(Exception wd){System.out.println("2"+wd);}
}
else
{
try{
stmt1=con1.createStatement();
stmt1.executeUpdate("insert into RESULT"+" values('"+urlAddress+"',"+frequency+")");
stmt1.close();
}catch(Exception we){System.out.println("3"+we);}
}
stmtAnother.close();
}catch(Exception wc){System.out.println("4"+wc);}
}
}
st.close();
con1.close();
}catch(Exception wb){System.out.println("5"+wb);}
//}
//}
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con1=DriverManager.getConnection("jdbc:odbc:search1","","");
}catch(Exception ws1){System.out.println("6"+ws1);}
stmt=con1.createStatement();
rs=stmt.executeQuery("select URLADDRESS from RESULT order by SUMFREQ desc");
%>
</font><font face="Bookman Old Style">
</font><font size="5" face="Bookman Old Style">
<ul style="color: #862B13; font-size: 12pt" type="square">
<%
//int size=0;
size = 0;
if(rs!=null)
{
while(rs.next())
{
urlname.addElement(rs.getString("URLADDRESS"));
size++;
}
stmt.executeUpdate("delete from RESULT");
stmt.close();
}
//////////////////////////
//////////////////////////
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con2=DriverManager.getConnection("jdbc:odbc:search2","","");
Statement st=con2.createStatement();
ResultSet result=st.executeQuery("select URLADDRESS,FREQUENCY from INDEXTABLE where KEYWORD like'"+tempString+"%'");
if(result!=null)
{
while(result.next())
{
String urlAddress=result.getString("URLADDRESS");
int frequency=Integer.parseInt(result.getString("FREQUENCY"));
try{
stmtAnother=con2.createStatement();
rsAnother=stmtAnother.executeQuery("select URLADDRESS from RESULT "+"where URLADDRESS='"+urlAddress+"'");
if(rsAnother.next())
{
try{
stmt1=con2.createStatement();
stmt1.executeUpdate("update RESULT"+" set SUMFREQ=SUMFREQ+"+frequency+" where URLADDRESS='"+urlAddress+"'");
stmt1.close();
}catch(Exception wd){System.out.println("2"+wd);}
}
else
{
try{
stmt1=con2.createStatement();
stmt1.executeUpdate("insert into RESULT"+" values('"+urlAddress+"',"+frequency+")");
stmt1.close();
}catch(Exception we){System.out.println("3"+we);}
}
stmtAnother.close();
}catch(Exception wc){System.out.println("4"+wc);}
}
}
st.close();
con2.close();
}catch(Exception wb){System.out.println("5"+wb);}
//}
//}
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con2=DriverManager.getConnection("jdbc:odbc:search2","","");
}catch(Exception ws1){System.out.println("6"+ws1);}
stmt=con2.createStatement();
rs=stmt.executeQuery("select URLADDRESS from RESULT order by SUMFREQ desc");
%>
</font><font face="Bookman Old Style">
</font><font size="5" face="Bookman Old Style">
<ul style="color: #862B13; font-size: 12pt" type="square">
<%
//int size=0;
size = 0;
if(rs!=null)
{
while(rs.next())
{
urlname.addElement(rs.getString("URLADDRESS"));
size++;
}
stmt.executeUpdate("delete from RESULT");
stmt.close();
}
//////////////////////////
//////////////////////////
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con3=DriverManager.getConnection("jdbc:odbc:search3","","");
Statement st=con3.createStatement();
ResultSet result=st.executeQuery("select URLADDRESS,FREQUENCY from INDEXTABLE where KEYWORD like'"+tempString+"%'");
if(result!=null)
{
while(result.next())
{
String urlAddress=result.getString("URLADDRESS");
int frequency=Integer.parseInt(result.getString("FREQUENCY"));
try{
stmtAnother=con3.createStatement();
rsAnother=stmtAnother.executeQuery("select URLADDRESS from RESULT "+"where URLADDRESS='"+urlAddress+"'");
if(rsAnother.next())
{
try{
stmt1=con3.createStatement();
stmt1.executeUpdate("update RESULT"+" set SUMFREQ=SUMFREQ+"+frequency+" where URLADDRESS='"+urlAddress+"'");
stmt1.close();
}catch(Exception wd){System.out.println("2"+wd);}
}
else
{
try{
stmt1=con3.createStatement();
stmt1.executeUpdate("insert into RESULT"+" values('"+urlAddress+"',"+frequency+")");
stmt1.close();
}catch(Exception we){System.out.println("3"+we);}
}
stmtAnother.close();
}catch(Exception wc){System.out.println("4"+wc);}
}
}
st.close();
con3.close();
}catch(Exception wb){System.out.println("5"+wb);}
//}
//}
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con3=DriverManager.getConnection("jdbc:odbc:search3","","");
}catch(Exception ws1){System.out.println("6"+ws1);}
stmt=con3.createStatement();
rs=stmt.executeQuery("select URLADDRESS from RESULT order by SUMFREQ desc");
%>
</font><font face="Bookman Old Style">
</font><font size="5" face="Bookman Old Style">
<ul style="color: #862B13; font-size: 12pt" type="square">
<%
//int size=0;
size=0;
if(rs!=null)
{
while(rs.next())
{
urlname.addElement(rs.getString("URLADDRESS"));
size++;
}
stmt.executeUpdate("delete from RESULT");
stmt.close();
}
int urls=urlname.size();
for(int i=0; i< urls; i++)
{
%>
<li>
<p align="left" style="margin-bottom: 5"><font face="Tahoma">
<a href=<%=urlname.elementAt(i).toString()%>><font color="#862B13">
<%=urlname.elementAt(i).toString()%></font></a></font><br>
</li>
</ul>
<b>
<font face="Bookman Old Style"> <font color="#FF9900" size="4">
<% } %>
Your search returns <%=urls%> results.</font>
<% } %>
</font>
<p align="left" style="margin-top: 0; margin-bottom: 0">
<font face="Book Antiqua" size="4" color="#FF9900"> </font></p>
</TD></TR>
</TBODY></TABLE></TD></TR></TBODY></TABLE>
</BODY>
</HTML>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -