📄 trainresult1.java
字号:
//列车查询2级结果,某一车次的所有到站信息
import java.io.*;
import java.text.*;
import java.sql.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
/**
*
*
* @author zhukejun
*/
public class TrainResult1 extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
HtmlOut htmlOut = new HtmlOut (response);
// 得到名字
String pass;
Person person = new Person();
person.setName (CommonMethods.GetUserName(request));
pass = CommonMethods.GetUserPass (request);
person.setPassword ( pass );
if( person.getName ()==null || (!person.checkPassword(pass)) )
{
htmlOut.setErrorID (htmlOut.SHOW_SIMPLE_MESSAGE ,"",
"请先登录!","Login?action=reLog");
htmlOut.outHtml();
return;
}
String auto,stationno,station,on_time,off_time,range,temp="";
//根据auto值来查询
auto=CommonMethods.getParameterValue(request,"auto");
String queryString="",sKey;
ResultSet rs;
SingleTemplate st;
DBOperater DB = new DBOperater ("train");
int nKey,i;
TemplateList tempList;
boolean flag=false;
tempList = CommonMethods.gettrain2Template ();
if( tempList == null ){
htmlOut.setErrorID (htmlOut.TEMPLATE_NOTFIND ,""
,"gettrain2Template error","TrainSearch");
htmlOut.outHtml ();
return;
}
st = tempList.searchTemplate("ROOT");
queryString="select stationno,station,on_time,off_time,range from train_info where auto='"
+CommonMethods.DealWithSQLParameter(auto)+"'";
rs=DB.executeQuery (queryString);
if(rs!=null)
{
try{
while(rs.next ())
{
stationno=rs.getString (1).trim ();
station=rs.getString (2).trim ();
on_time=rs.getString (3).trim ();
off_time=rs.getString (4).trim ();
range=rs.getString (5).trim ();
flag=true;
temp=temp+"<tr align=middle bgcolor=#E3E5E5>"+"<td>"+stationno+"</td>"+
"<td>"+station+"</td>"+
"<td>"+on_time+"</td>"+
"<td>"+off_time+"</td>"+
"<td>"+range+"</td>"+"</tr>";
}
if(flag==false)
{
htmlOut.setErrorID (htmlOut.SHOW_SIMPLE_MESSAGE ,"",
"没有您要的信息!"
,"TrainSearch" );
DB.close ();
htmlOut.outHtml ();
return;
}
nKey = st.getKeyNum ();
for(i=0;i<nKey;i++)
{
htmlOut.addString (st.getStringAt (i));
sKey = st.getKeyAt (i);
if( sKey .compareTo("cgi-path")==0 )
htmlOut.addString (CommonMethods.sHostNameCGI);
if(sKey.compareTo ("内容")==0)
htmlOut.addString(temp);
}
htmlOut.addString (st.getEndString () );
htmlOut.outHtml();
}catch(Exception e){
}
}
DB.close ();
}
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
doGet(request,response);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -