%@page import="javabean.db_conn"%>
<%@page import="java.sql.ResultSet"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page contentType="text/html; charset=UTF-8" import="java.util.Date"%>
<%@page contentType="text/html; charset=UTF-8" import="java.text.SimpleDateFormat"%>
<%
// 检查用户是否已登录
if (session.getAttribute("user_id") == null) {
// 如果未登录,重定向到登录页面
response.sendRedirect("../index/login_reg.jsp");
return;
}
// 添加URL session ,作为用户登录后跳转回来的依据,登录servlet中已经写了判断程序,如果有url_cookie,就跳转到url_cookie,如果没有,就跳转到用户中心
session.setAttribute("url", request.getRequestURI());
%>
机票推荐系统
<%!
String user_name,seat;
Date date = new Date();
//设置要获取到什么样的时间
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//获取String类型的时间
String todaydate = sdf.format(date);
%>
<%
db_conn conn=new db_conn();
String sql="select * from flight";
ResultSet res=conn.executeQuery(sql);
while(res.next()){
String f_i=res.getString(1);
String s_p=res.getString(2);
String a_p=res.getString(3);
String s_a=res.getString(4);
String a_a=res.getString(5);
String s_t=res.getString(6);
String a_t=res.getString(7);
String f_p=res.getString(8);
String f_d=res.getString(9);
String f_delay=res.getString(10);
String f_food=res.getString(11);
String f_wide=res.getString(12);
/*
String sql2="select sum(t_b) from ticket where f_n='"+f_i+"' and t_d='"+todaydate+"'";
db_conn conn2=new db_conn();
ResultSet res2=conn2.executeQuery(sql2);
if(res2.next()) seat=res2.getString(1);
if(seat=="null") seat="0";
*/
db_conn conn3=new db_conn();
String a_code="";//出发地机场三字码
String d_code="";//到达地机场三字码
String sql3="SELECT code FROM codetoname WHERE airportname = '"+a_a+"'";
String sql4="SELECT code FROM codetoname WHERE airportname = '"+s_a+"'";
ResultSet res3=conn3.executeQuery(sql3);
if(res3.next()) a_code=res3.getString(1);
ResultSet res4=conn3.executeQuery(sql4);
if(res4.next()) d_code=res4.getString(1);
String Domainname="https://flights.ctrip.com/";
Domainname+="online/list/oneway-"+d_code+"-"+a_code+"?_=1&depdate="+f_d+"&containstax=1";
%>
- <%=f_i %>
- <%=s_p %>
- <%=s_a %>
- —
- <%=a_p %>
- <%=a_a %>
- <%=s_t %>
- —
- <%=a_t %>
<%if(session.getAttribute("user_id")!=null){ %>
<%}
if(session.getAttribute("user_id")==null){ %>
<%} %>
- 价格:¥<%=f_p %>
- 延误率:<%=f_delay %>
- 餐食:<%=f_food %>
- 座位宽度:<%=f_wide %>
- 出发日期:<%=f_d %>
<%
}
%>