public void showTrainList(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
            /* TODO output your page here. You may use following sample code. */
            String stnFrom = request.getParameter("txtStationFrom");
            String stnTo = request.getParameter("txtStationTo");
            String date = request.getParameter("txtDate");

            StationMasterData objSMD = new StationMasterData();
            StationMaster stationFrom = objSMD.getStation(stnFrom);
            StationMaster stationTo = objSMD.getStation(stnTo);

            BookingDetails bookingDetails;
            /*
             if(request.getSession().getAttribute("BookingDetails") == null){
             bookingDetails = new BookingDetails();
             }
             else{
             bookingDetails = (BookingDetails)request.getSession().getAttribute("BookingDetails");
             }*/

            ArrayList<TrainMaster> arrTrains = new TrainMasterData().getTrains();
            ArrayList<TrainSchedule> arrSchedules = new TrainScheduleData().getSchedules();

            ArrayList<BookingDetails> arrBookingDetails = new ArrayList<BookingDetails>();

            int count, fromDistance, toDistance;

            for (TrainMaster train : arrTrains) {
                count = 0;
                toDistance = 0;
                fromDistance = 0;
                bookingDetails = new BookingDetails();
                for (TrainSchedule schedule : arrSchedules) {
                    if (schedule.getTrainId() == train.getTrainId() && schedule.getTrainDate().equals(date)) {
                        if (schedule.getStationId() == stationFrom.getStationId()) {
                            count = 1;
                            bookingDetails.setDepartureTime(schedule.getDeparture());
                            bookingDetails.setScheduleFromId(schedule.getScheduleId());
                            fromDistance = schedule.getDistance();
                            continue;
                        }
                        if (schedule.getStationId() == stationTo.getStationId()) {
                            if (count == 1) {
                                count = 2;
                                bookingDetails.setArrivalTime(schedule.getArrivalTime());
                                bookingDetails.setScheduleToId(schedule.getScheduleId());
                                toDistance = schedule.getDistance();
                                break;
                            }
                        }
                    }
                }
                if (count == 2) {
                    bookingDetails.setTrainDate(date);
                    bookingDetails.setTrainName(train.getTrainName());
                    bookingDetails.setTrainNo(train.getTrainNumber());
                    bookingDetails.setTrainType(train.getTrainType());
                    bookingDetails.setStationFrom(stnFrom);
                    bookingDetails.setStationTo(stnTo);
                    bookingDetails.setTrainId(train.getTrainId());
                    bookingDetails.setDistance(toDistance - fromDistance);
                    bookingDetails.setStationFromId(stationFrom.getStationId());
                    bookingDetails.setStationToId(stationTo.getStationId());
                    arrBookingDetails.add(bookingDetails);
                }
            }

            TicketBookingMaster objTBM;
            TicketBookingMasterData objTBMData = new TicketBookingMasterData();
            String innerList = "<div style=\"margin: 0 auto; width: 150px\" ><h4 style=\"color: #4391df\">List of Trains</h4></div>\n<br />\n";
            innerList += "                <table>\n"
                    + "                    <th style=\"width: 80px;\">Train No</th>\n"
                    + "                    <th style=\"width: 150px;\">Train Name</th>\n"
                    + "                    <th style=\"width: 80px;\">Departs</th>\n"
                    + "                    <th style=\"width: 80px;\">Arrives</th>\n"
                    + "                    <th style=\"width: 40px;\">1A</th>\n"
                    + "                    <th style=\"width: 40px;\">FC</th>\n"
                    + "                    <th style=\"width: 40px;\">2A</th>\n"
                    + "                    <th style=\"width: 40px;\">3A</th>\n"
                    + "                    <th style=\"width: 40px;\">3E</th>\n"
                    + "                    <th style=\"width: 40px;\">CC</th>\n"
                    + "                    <th style=\"width: 40px;\">SL</th>\n"
                    + "                    <th style=\"width: 40px;\">2S</th>\n";
            count = 1;

            for (BookingDetails bd : arrBookingDetails) {
                objTBM = objTBMData.getTBMDetails(bd.getTrainId(), bd.getTrainDate());
                innerList += "                    <tr>\n"
                        + "                        <td>" + bd.getTrainNo() + "</td>\n"
                        + "                        <td>" + bd.getTrainName() + "</td>\n"
                        + "                        <td style=\"text-align: center;\">" + bd.getDepartureTime() + "</td>\n"
                        + "                        <td style=\"text-align: center;\">" + bd.getArrivalTime() + "</td>\n"
                        + "                        <td style=\"text-align: center;\">" + getTrainClassValue("1A", objTBM, count) + "</td>\n"
                        + "                        <td style=\"text-align: center;\">" + getTrainClassValue("FC", objTBM, count) + "</td>\n"
                        + "                        <td style=\"text-align: center;\">" + getTrainClassValue("2A", objTBM, count) + "</td>\n"
                        + "                        <td style=\"text-align: center;\">" + getTrainClassValue("3A", objTBM, count) + "</td>\n"
                        + "                        <td style=\"text-align: center;\">" + getTrainClassValue("3E", objTBM, count) + "</td>\n"
                        + "                        <td style=\"text-align: center;\">" + getTrainClassValue("CC", objTBM, count) + "</td>\n"
                        + "                        <td style=\"text-align: center;\">" + getTrainClassValue("SL", objTBM, count) + "</td>\n"
                        + "                        <td style=\"text-align: center;\">" + getTrainClassValue("2S", objTBM, count) + "</td>\n"
                        + "                    </tr>\n";
                count++;
            }
            innerList += "</table>";

            request.getSession().setAttribute("BookingDetails", arrBookingDetails);
            out.print(innerList);
            //ArrayList<StationMaster> arrStations = request.getSession();
        } finally {
            out.close();
        }
    }