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

📄 resultadvance2.jsp

📁 基于JSP的公交查询系统,很好用的,适于学习,操作语句全在jsp页面里
💻 JSP
📖 第 1 页 / 共 2 页
字号:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="java.util.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>站点查询</title>
<style type="text/css">
a,body,tr,td {
	text-align: center;
	font-family: 宋体;
	font-size: 13px
}
</style>
</head>

<body>
<%     Connection con;
         ResultSet result,result1,result2,result3;
		 //定义三个sql对象
		 Statement sql3=null;
		 Statement sql1=null;
		 Statement sql2=null;
		 String conditione[][]=new String[50][50];//存放查询语句,
		 String conditions[][]=new String[50][50];//存入查询语句
		 
		 int i=0,j=0,k,h=0,m=0,n;
		 //用来存放含有起始站而不含有终止站的车次号和细节
		 String S_BusID[]=new String[50];
		 String S_Detail[]= new String[50];
		 //用来存放含有终止站而不含有起始站的车次号和细节
		 String E_BusID[]=new String[50];
		 String E_Detail[]=new String[50];
		 //用来存储在起始站和终止站在同一车次的车次号
		 String Result1[]=new String[50]; //用来存放有直达车时的车次号
		 String Detail[]=new String[50]; //用来存放有直达车时的所有站点信息
		 String stations[]=new String[100];  //用来存放某一路车次的所有站点
		 
		 String all_station[]=new String[2000]; //用来存入所有站点信息
		 String matchs[]=new String[100]; //存放包含起始站点的关键字所有站点
		 String matche[]=new String[100]; //存放包含终止站点的关键字所有站点
		 int counts=0; //计算包含起始站点关键字所有站点的个数
		 int counte=0; //计算包含终止站点关键字所有站点的个数
		 int flag1=0,flag=0;
		 
		 String station1=null;
		 String station2=null;
		 String detail1=null;
		 String detail2=null;
		 String detail=null; //计算所有站点时,用来存入临时站点信息
		 
		 String Result2_ID1[]=new String[500];//中转车次一
		 String Result2_ID2[]=new String[500];//中转车次二
		 String Result2_tan[]=new String[500];//中转站
		 int count=0;
		 //获取表单信息(起始站和终止站)
		 int countallstation=0;//
		 //获取表单信息(起始站和终止站)
		 String S_Station=new String(request.getParameter("s_station").getBytes("ISO8859_1"),"GBK");
		 String E_Station=new String(request.getParameter("e_station").getBytes("ISO8859_1"),"GBK");
		 
		 try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
		      }
			 catch(ClassNotFoundException e){  e.printStackTrace(); } 
			try{   //加载数据源
			       con=DriverManager.getConnection("jdbc:odbc:nbos","",""); 
				   sql1=con.createStatement(); 
				   //从数据库中找出所有含有起始站和终止站的数据
			       String condition1="select * from bus where Detail LIKE '%"+S_Station+"%"+E_Station+"%' OR Detail LIKE '%"+E_Station+"%"+S_Station+"%'";
				   result1=sql1.executeQuery(condition1);
				    //把结果放在数组Result1[i]中
				   while(result1.next())
				     { 
				       Result1[i]=result1.getString("BusID");
					   Detail[i]=result1.getString("Detail");
					   i++;
					   
					 } 
					 result1.close();//关闭第一个结果集
		          if(i>0)		 
				   
				    { 
 //当起始站到终止站在同一车次时,输出以下表格
				      %>
<base target="_blank">
<TABLE cellSpacing=1 cellPadding=3 width=650 align=center bgColor=#003399 
border=0>
  <TBODY>
    <TR>
      <TD background=Picture/topbg.gif height=20></TD>
    </TR>
    <TR bgColor=#7da4ec>
      <TD><STRONG><FONT color=#ffffff>站站查询结果</FONT></STRONG></TD>
    </TR>
    <TR bgColor=#e8f3ff>
      <TD><!--查询结果显示开始-->
          <TABLE width=500 height="84" border=0 cellPadding=3 cellSpacing=1 bgColor=#003399>
            <TBODY>
              <TR bgColor=#fddd90>
                <TD height="19" colspan="2"><!--查询结果显示开始-->
                    <p><font color="FF0000"><%=S_Station%></font>到<font color="FF0000"><%=E_Station%></font>有直达车,请参考以下车次!</p></TD>
              </TR>
              <TR bgColor=#fddd90>
                <TD width=73 height="19"><strong>车次号</strong></TD>
                <TD width="412"><strong>经过的所有站点</strong></TD>
              </TR>
              <% 
//循环输出起点站和终点站在同一车次的所有车次,i是表示满足条件的车次我个数
        for(int mark=0;mark<i;mark++)
	            {   
			     StringTokenizer str1=new StringTokenizer(Detail[mark],"->");
			     count=0;
		         while(str1.hasMoreTokens())
		          { stations[count]=str1.nextToken();
			         count++;
			      }//endwhile
			  
			 
			   %>
              <TR onmouseover="this.style.backgroundColor = '#FFF9EE'" 
        onmouseout="this.style.backgroundColor = ''" bgColor=#e8f3ff>
                <TD height="42"><%=Result1[mark]%></TD>
                <TD>
                  <div align="left">
                    <%   
//按某种格式输出某一车次的所有信息
		  for(int countstation=0;countstation<count;countstation++)
		    {  if(stations[countstation].indexOf(S_Station)!=-1)
		         {  %>
                    <font color="#FF0000"><%=stations[countstation]%> &nbsp;</font>
                    <% }//endif
				  else  
				     if(stations[countstation].indexOf(E_Station)!=-1)
		               {  %>
                    <font color="#0000FF"><%=stations[countstation]%> &nbsp;</font>
                    <% }//endif
				  
				     else    { %>
                    <font size="2"><%=stations[countstation]%>&nbsp;</font>
                    <% 
                  }//endelse
		 }//endfor			
			  
				 
			  	
		  %>
                </div></TD>
              </TR>
              <%      } //end for(int m=0;m<count;m++)
	          //end else
		
		 
	    
		
		%>
            </TBODY>
          </TABLE>
          <!--查询结果显示结束-->
          <BR>
          <IMG 
      src="Picture/close_window.gif" width="78" height="21" border=0 
      style="CURSOR: hand" onclick=window.close()> </TD>
    </TR>
    <TR>
      <TD background=Picture/bottombg.gif 
height=20></TD>
    </TR>
  </TBODY>
</TABLE>
<%     } else   //当起始站等于终止站,且没有回路时,跳转至错误提示页面
              if(S_Station.equals(E_Station))
                        { response.sendRedirect("errorquery3.jsp");
						   }
						   else{ 
 //不重复地计算所有站点,放入all_station[count]				
            // out.println("dfsf");   
			 Statement sql=con.createStatement(); 
		     String statement="select * from bus";
		     result=sql.executeQuery(statement);
		     if(result.next())
		      {   detail=result.getString("Detail");
			    // out.println(detail);
			     StringTokenizer str=new StringTokenizer(detail,"->");
			     while(str.hasMoreTokens())
		            { all_station[countallstation]=str.nextToken();
					  
					  countallstation++;
					 }//endwhile
			  }//endif
			   
			   while(result.next())
			    
			    {    detail=result.getString("Detail");
				     //out.println(detail);
			        StringTokenizer str1=new StringTokenizer(detail,"->");
				    while(str1.hasMoreTokens())
				       { flag1=0;
					     station2=str1.nextToken();
					    //out.println(station2);
					     for(int b=0;b<countallstation&&flag1==0;b++)
						  { station1=all_station[b];
						   // out.println(station1);
					        if(station1.equals(station2))
						      { flag1=1;
							    flag=0;
							  }
							  else
							    flag=1;
						  }	//for  

⌨️ 快捷键说明

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