logout.java~4~

来自「采用web2.0技术,采用动态标签,sql语句全部存储在数据库里面.开发速度快.」· JAVA~4~ 代码 · 共 96 行

JAVA~4~
96
字号
package com.sztheater.framework.web;
import javax.servlet.*;
import javax.servlet.jsp.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.sql.*;
import com.sztheater.framework.util.*;
import com.sztheater.biz.order.*;
/**
 * <p>Title:用户登录退出</p>
 */
public class Logout extends HttpServlet {
    public Logout() {
    }

    public void init() throws ServletException {
    }

    public void doGet(HttpServletRequest request,HttpServletResponse response)
           throws ServletException, IOException {
                HttpSession _httpSession  = null;
                int         iSuccFlag = 0;
        Statement stmt = null;
        Connection conn = null;
        ResultSet  rs = null;
        String strSQL    = "";
        ArrayList resultField = null;

                String username = null;
                String programid = null;
                String seatid    = null;
                String strMsg    = null;
                HashMap aHash    = null;
                int    iLoop     = 0;
                int    iLoopNum  = 0;
                boolean flag = false;
        _httpSession = request.getSession();
        try{
        if(_httpSession!=null){

                username  = (String)_httpSession.getAttribute("username");

                if ( username == null || username.equals("") ) {

                        username = "";
                        username = username.trim();


                        }else {
                                try {
                conn = DbFunc.getConnection(false);
             } catch (Exception e) {
                iSuccFlag = -90102;
                if (conn != null) {
                    DbFunc.free(conn, iSuccFlag);
                }
                conn = null;
                strMsg = "服务取数据库连接异常" + e.getMessage();
                }

                                strSQL  = "select * from t_order_cart where username = '"+username+"'";

                            resultField = new ArrayList();
                                DbFunc.getRecordSet(-900012,"",conn,strSQL,resultField);
                                System.out.println("resultField**"+resultField);
                                iLoopNum = resultField.size();
                             for (iLoop=0;iLoop<iLoopNum;iLoop++){
                                        aHash  = (HashMap)resultField.get(iLoop);

                                    programid = (String)aHash.get("programid");
                                    seatid    = (String)aHash.get("seatid");

                                    strSQL = "update t_ticketingseat set \n"
                                                +"statusid = 0 where programid='"+programid+"' \n"
                                                +" and seatid='"+seatid+"' ";
                                    flag = ModifyData.ModifyTicketingSeat(strSQL);
                                }
                                    /*if update t_ticketingseat success then delete the t_order_cart*/
                                if (flag) {

                                  strSQL = "delete from t_order_cart where username='"+username+"'"	;
                                  iSuccFlag = DbFunc.runsql(strSQL);

                                        }
                        }
                }
                _httpSession.invalidate();
                response.sendRedirect("/SZTheater/index.jsp");
        }catch(Exception ex){
                ex.printStackTrace();
                }

    }
}

⌨️ 快捷键说明

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