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

📄 hbservlet.java

📁 JAVA邮件系统
💻 JAVA
字号:
/* 
 *  HbServlet.java
 */

import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

/**
 *
 * @author Liyan
 */

//The class hand the Http request
public class HbServlet extends HttpServlet {


    public void doGet(HttpServletRequest request,
                      HttpServletResponse response)
        throws IOException, ServletException
    {
		HtmlOut htmlOut = new HtmlOut (response);

		Person p=new Person();
		p.setName (CommonMethods.GetUserName(request));
		String pass = CommonMethods.GetUserPass (request);
		if( p.getName ()==null || (!p.checkPassword(pass)) )
		{
	    	htmlOut.setErrorID (htmlOut.SHOW_SIMPLE_MESSAGE ,"",
								"请先登录!","Login?action=reLog");
			htmlOut.outHtml();
			return;
		}

		//基本参数:
		String flag=request.getParameter("flag");
		System.out.println (flag);
		HbChannel hbChannel=new HbChannel();

		String action=request.getParameter("action");
		if( action != null && action.compareTo("tx")==0 ){
			boolean b = hbChannel.makeTX(p,htmlOut,request);
			if( b==false ){
				htmlOut.outHtml();
				return;
			}
		}
		
		if (flag==null)
		{
			htmlOut.addString("<body background=\"/img/bg1.gif\">");
		}else {
			
			if (flag.compareTo("jhhbh")==0) //航班计划按航班号查询
			{
				String sHtmlOut="";
				String sHbh=request.getParameter("hbh");
				TemplateList tempList=CommonMethods.getHbjh_MainTemplate();
				hbChannel.makeHbjh_Hbh(p,tempList,htmlOut,sHbh);
			}
			
			if (flag.compareTo("jhline")==0) //航班计划按航线查询
			{

				String sFrom = CommonMethods.DealWithGBCodeOfRequest(request.getParameter("from"));
				String sTo = CommonMethods.DealWithGBCodeOfRequest(request.getParameter("to"));
				String sDate = CommonMethods.DealWithGBCodeOfRequest(request.getParameter("date"));
			
				if(sFrom==null)
					sFrom="";
				if(sTo==null)
					sTo="";
				if(sDate==null)
					sDate="";
				//取得文件夹主模板:
				TemplateList tempList=CommonMethods.getHbjh_MainTemplate();
				hbChannel.makeHbjh_Line(p,tempList,htmlOut,sFrom,sTo,sDate);
			}
			
			if (flag.compareTo("jhcompany")==0) //航班计划按航空公司查询
			{
				String sEzdm = request.getParameter("ezdm");
				String sPage = request.getParameter("page");
				if(sPage==null)
				   sPage="1";
				if(sEzdm!=null){
					//取得文件夹主模板:
					TemplateList tempList=CommonMethods.getHbjh_MainTemplate();
					hbChannel.makeHbjh_Company(p,tempList,htmlOut,sEzdm,sPage);
				}
			}
			
			if (flag.compareTo("dthbh")==0) //航班动态按航班号查询
			{
				String sHtmlOut="";
				String sHbh=request.getParameter("dthbh");
				TemplateList tempList=CommonMethods.getHbdt_MainTemplate();
				hbChannel.makeHbdt_Hbh(p,tempList,htmlOut,sHbh);
			}
			
			if (flag.compareTo("dtline")==0) //航班动态按航线查询
			{
				String sFrom=CommonMethods.DealWithGBCodeOfRequest(request.getParameter("from2"));
				String sTo=CommonMethods.DealWithGBCodeOfRequest(request.getParameter("to2"));
				TemplateList tempList=CommonMethods.getHbdt_MainTemplate();
				hbChannel.makeHbdt_Line(p,tempList,htmlOut,sFrom,sTo);
			}
			
			if (flag.compareTo("dtcompany")==0) //航班动态按公司查询
			{
				String sEzdm = request.getParameter("dtezdm");
				String sPage = request.getParameter("page");
				if(sPage==null)
				   sPage="1";
				
				if(sEzdm!=null){
					//取得文件夹主模板:
					TemplateList tempList=CommonMethods.getHbdt_MainTemplate();
					hbChannel.makeHbdt_Company(p,tempList,htmlOut,sEzdm,sPage);
				}
			}
			
			if (flag.compareTo("dttxadd")==0) //航班动态提醒数据添加
			{
				//航班号、提醒地名、进出港、日期、提前时间
				String sHbh = request.getParameter("hbh");
				String sDmdm = CommonMethods.DealWithGBCodeOfRequest
					( request.getParameter("dmdm"));
				String sInout = request.getParameter("inout");
				String sZxrq = request.getParameter("zxrq");
				String sTqtx = request.getParameter("tqtx");
				String sType = request.getParameter("type");
				
				if((sHbh.trim().length()<1)||(sDmdm.trim().length()<1)||(sTqtx.trim().length()<1)){
					htmlOut.addString("输入数据不全!");
					htmlOut.addString("<br><a href=EditChannel?channel=Hb>返回</a>");
					htmlOut.outHtml();
					return;
				}
				Hbtx hbtx = new Hbtx();
				int nFlag = hbtx.isDttxValid(p,sHbh,sInout,sDmdm);
				if(nFlag==1)
				{
					htmlOut.addString("输入数据有误!");
					htmlOut.addString("<br><a href=EditChannel?channel=Hb>返回</a>");
					htmlOut.outHtml();
					return;
				}
				
				if(nFlag==2)
				{
					htmlOut.addString("数据已经入库!");
					htmlOut.addString("<br><a href=EditChannel?channel=Hb>返回</a>");
					htmlOut.outHtml();
					return;
				}
				
				hbtx.addDttx(p.getName(),sHbh,sDmdm,sInout,sZxrq,sTqtx,sType);
				htmlOut.addString("ok!");
				response.sendRedirect("EditChannel?channel=Hb");
				
			}
			
			if (flag.compareTo("dttxdel")==0) //航班动态提醒数据删除
			{
				String sHbh = request.getParameter("hbh");
				String sDmdm = CommonMethods.DealWithGBCodeOfRequest(request.getParameter("dmdm"));
				Hbtx hbtx = new Hbtx();
				hbtx.deleteTxData(p,sHbh,sDmdm);
				response.sendRedirect("EditChannel?channel=Hb");
			}
		}
		htmlOut.outHtml();
    }
	

	
    public void doPost(HttpServletRequest request,
                      HttpServletResponse response)
        throws IOException, ServletException
    {
        doGet(request, response);
    }
}

⌨️ 快捷键说明

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