Member 13060088 Ответов: 0

Получить данные из сессии сервлета в JSP страницу, без перезагрузки страницы


Привет,
Я разрабатываю веб-приложение, используя Eclipse Luna для программирования и SQL для базы данных.
Я застрял где-то в коде, но не могу сделать это после стольких испытаний.
Настоящим я прилагаю свой код и страницу jsp. Я действительно получаю данные, которые мне нужны для отображения, но проблема в том, что для каждого нового ввода вы должны обновлять веб-страницу. В противном случае вы получаете ту же запись, которая была последним вводом. Пожалуйста, помогите мне.

Что я уже пробовал:

Сервлет DigitRef:

package servlets;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import bo.Allgetset;

import com.dao.AllDao;

/**
 * Servlet implementation class DigitRef
 */
@WebServlet("/DigitRef")
public class DigitRef extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public DigitRef() 
    {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		System.out.println("digitRef Get");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		
		System.out.println("hello cardnumber chk");
		 
		HttpSession session=request.getSession(true);
		session.removeAttribute("Unbe");
		try
		{
			System.out.println("Inside DigitRef");
		AllDao ad=new AllDao(); 
		
		String cardNo=request.getParameter("cardnumber");
		System.out.println(cardNo);
		// check if the cardnumber is 22 digit?
		
		if (cardNo.length()!=22)
		{
		// error message if No 22 digits
			
			System.out.println("no 22 digits");
//			session.removeAttribute("Unbe");
			session.setAttribute("Unbe", "Unbekannte Karte");
			RequestDispatcher rs = request.getRequestDispatcher("TabStartseit.jsp");
			rs.include(request, response);
			
		}
	
		// check if card belongs to BWM or not?
		
		else if(!ad.CheckCompany(cardNo.substring(0,7)))
		{
			
		// error message if  NO BWM card
			//insert to db
			try {
				ad.insertIfNotBwm(cardNo, "Not BWM card");
			} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (InstantiationException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			System.out.println("Not BWM card");
//			session.removeAttribute("Unbe");
			session.setAttribute("Unbe", "Unbekannte Karte");
			RequestDispatcher rs = request.getRequestDispatcher("TabStartseit.jsp");
			rs.include(request, response);
			
		}
		// check if card is KaufKarte or Meldewesen Karte?
			
		else if (ad.chkPre(cardNo.substring(0,4)))
						{
		//  Output Kaufkarte / Prepaid
			
			System.out.println("Prepaid card / Kauf Karte / Kunden Karte");
//			session.removeAttribute("cardNo");
			session.setAttribute("cardNo", cardNo);
			
			
			String s1=(String) session.getAttribute("user");
			System.out.println(s1);
			
			List<Allgetset> servicesList=ad.getServices(session.getAttribute("user").toString(),session.getAttribute("pass").toString());
			System.out.println(servicesList.size());
			
		for(Allgetset s:servicesList) 
						{ 
							System.out.println("Services for Kaufkarte");
							System.out.println(s.getService());
						}
//		session.removeAttribute("servicejsp");
		session.setAttribute("servicejsp", servicesList);
		
		 if(servicesList.size()==1)
		 {
//			 session.removeAttribute("disable");
			 session.setAttribute("disable", "disabled=disabled");
			 System.out.println("===========================================================================");
			 RequestDispatcher rs = request.getRequestDispatcher("Leis1");
			 rs.forward(request, response);
		 }
		 else if(servicesList.size()>1)
		 {
//			 session.removeAttribute("autodisable");
			 session.setAttribute("autodisable", "true");
			 RequestDispatcher rs = request.getRequestDispatcher("Leis1");
			 rs.forward(request, response);
		 }
		 else
		 {
//			 session.removeAttribute("disable");
			 session.setAttribute("disable", "");
		RequestDispatcher rs = request.getRequestDispatcher("TabStartseit.jsp");
	    rs.forward(request, response);
		 }
		
		}
		
		else 
			
		{
			
		// Output  Meldewesen Karte
			
			System.out.println("Instant card / Meldewesen Karte");
			String s1=(String) session.getAttribute("user");
			
			System.out.println(s1);
			List<Allgetset> servicesList=ad.getServices(session.getAttribute("user").toString(),session.getAttribute("pass").toString());
					
			System.out.println("servListSize:"+servicesList.size());
			System.out.println("service :"+servicesList.get(0).getService());

		for(Allgetset s:servicesList) 
						{ 
							System.out.println("Services for Meldewesen Karte");
							System.out.println("service :"+s.getService());
						}
//		 	session.removeAttribute("cardNo");
			session.setAttribute("cardNo", cardNo);
			 
//			 session.removeAttribute("servicejsp");
			 session.setAttribute("servicejsp", servicesList);
			 if(servicesList.size()==1)
			 {
//				 session.removeAttribute("disable");
				 session.setAttribute("disable", "disabled=disabled");
				 System.out.println("===========================================================================");
				 RequestDispatcher rs = request.getRequestDispatcher("Leis1");
				 rs.forward(request, response);
			 }
			 else if(servicesList.size()>1)
			 {
//				 session.removeAttribute("autodisable");
				 session.setAttribute("autodisable", "true");
				 RequestDispatcher rs = request.getRequestDispatcher("Leis1");
				 rs.forward(request, response);
			 }
			 else
			 {
//				 session.removeAttribute("disable");
				 session.setAttribute("disable", "");
				 System.out.println("===========================================================================2");
			 RequestDispatcher rs = request.getRequestDispatcher("TabStartseit.jsp");
			 rs.forward(request, response);
			 }
		}
		
		
		} 
		catch (SQLException e) 
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}


Сервлет Leis1:


package servlets;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.dao.AllDao;

import bo.Allgetset;

import java.sql.SQLException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * Servlet implementation cla<pre><pre lang="java">ss Leis1
 */
@WebServlet("/Leis1")
public class Leis1 extends HttpServlet 
{
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Leis1() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		System.out.println("Inside leis1");
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		HttpSession session=request.getSession(true);
		
		
		
		String carNo=(String) session.getAttribute("cardNo");
		System.out.println(carNo);
		String id;

		id = UUID.randomUUID().toString();
		
		String id1;

		id1 = UUID.randomUUID().toString();
		
		
		
		String id2;
		
		id2 = UUID.randomUUID().toString();
	
		Allgetset allgs=new Allgetset();
		AllDao ad=new AllDao();
		try 
		{
			System.out.println("Inside Leis1");
			String idLeistung="";
			List<Allgetset> li=ad.getCardData(carNo);
			List<Allgetset> gastDetails=ad.getGastCardDetails(carNo);
			String idGastCardType=li.get(0).getIdGastCardType();
			String endDate=li.get(0).getCardExpiry();
			
			
//			Date result =  li.get(0).getCardExpiry().parse(endDate);
//            System.out.println(result); 

			    
			    
			int usableDays=li.get(0).getGct_Nutzungstage();
			int withinDays=li.get(0).getGct_Nutzungsdauer();
			System.out.println("idGastCardType= " + idGastCardType);
			
		
			List<Allgetset> servList=(List<Allgetset>) session.getAttribute("servicejsp");
			System.out.println("Leistungen= "+servList.size());
			String autoDis=(String)session.getAttribute("autodisable");
			int autoDisableCnt=0;
			if(servList.size()==1)
			{
				for(Allgetset all:servList)
				{
					idLeistung=all.getIdLeistun();
				}
			}
			else if(autoDis.equalsIgnoreCase("true"))
			{
				autoDisableCnt=1;
				System.out.println("Inside Autodisable");
				
				for(Allgetset all:servList)
				{
					idLeistung=all.getIdLeistun();
					try
					{
						if(carNo.length()==22)
						{
							String barCode=carNo;
							
							String gac_KartenTypeCode=carNo.substring(0,7);
							System.out.println("gac_KartenTypeCode= "+gac_KartenTypeCode);
							
							String  gac_KartenNummer=carNo.substring(7,14);
							System.out.println("gac_KartenNummer= "+gac_KartenNummer);
							
							String gac_Klasse=carNo.substring(4,5);
							System.out.println("gac_Klasse= "+gac_Klasse);
							
							String gac_Kategorie=carNo.substring(5,7);
							System.out.println("gac_Kategorie= "+gac_Kategorie);
							
							String gac_Aufenthaltsdauer=carNo.substring(18,21);
							System.out.println("Days Stay= "+gac_Aufenthaltsdauer);
							int auf=Integer.parseInt(gac_Aufenthaltsdauer);
							String year=carNo.substring(14,15);
							System.out.println("Arrival year= "+year);
							
							String dayOfYear1=carNo.substring(15,18);
							System.out.println("Arrival Day of Year= "+dayOfYear1);
						
							
							// Program for recognizing Leap year 
							
							SimpleDateFormat format2 = new SimpleDateFormat("EEEE, d. MMMM y",Locale.GERMANY);
							Date date2=new Date();
							String d2 = format2.format(date2);
							System.out.println("d2 :"+d2.substring(d2.length()-4,d2.length()));
							int arrival_yr=Integer.parseInt(d2.substring(d2.length()-4,d2.length()-1).trim()+year.trim());
							year=d2.substring(d2.length()-4,d2.length());
							
							// total no of days in a year 
							
							int NoOfDays_yr=365;
							GregorianCalendar gre_cal = new GregorianCalendar();
							
							if(gre_cal.isLeapYear(arrival_yr))
							{
							    System.out.print("Given year is leap year.");
							    NoOfDays_yr=366;
							}
							
						

//							Calendar cal2 = Calendar.getInstance();
//							SimpleDateFormat format2 = new SimpleDateFormat("EEEE, d. MMMM y",Locale.GERMANY);
////							Date date=new Date();
//							String d2 = format2.format(01-01-2016);
//							Date date1;
//							try {
//								date1 = format2.parse(d2);
//								cal2.setTime(date1);
//								
//								int numOfDays = cal2.getActualMaximum(Calendar.DAY_OF_YEAR);
//								System.out.println("No of days"+numOfDays);
//							} catch (ParseException e1) {
//								// TODO Auto-generated catch block
//								e1.printStackTrace();
//							}
							
							
							//  calculating the dates
							
							int dayOfYear = Integer.parseInt(dayOfYear1);
							int dayOfYear_auf = Integer.parseInt(gac_Aufenthaltsdauer);
							int lastDay=dayOfYear+dayOfYear_auf;
					        Calendar calendar = Calendar.getInstance();
					        calendar.set(Calendar.DAY_OF_YEAR, dayOfYear);
					        calendar.set(Calendar.YEAR, arrival_yr);
					        System.out.println("Guest's Arrival Day= " + dayOfYear );
					        Date arrival_date_cust=calendar.getTime();
					      
					        System.out.println("Arrival Date of Guest :"+arrival_date_cust);
							SimpleDateFormat format1 = new SimpleDateFormat("EEEE, d. MMMM y",Locale.GERMANY);
							System.out.println("Guest's Arrival Date= " + calendar.getTime());
							System.out.println();
							java.util.Date utilDate = (arrival_date_cust);
									SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
									final String stringDate= dateFormat.format(utilDate);
									final java.sql.Date sqlDate=  java.sql.Date.valueOf(stringDate);
							
							// Output Guest's Arrival & Departure day

							String gac_Anreise = format1.format( calendar.getTime());
//							  java.util.Date myDate = new java.util.Date(format1.format(gac_Anreise));
//								 java.sql.Date sqlDate = new java.sql.Date(myDate.getTime());
//							
								
							 
							if(NoOfDays_yr==366)
							{
								if(lastDay>366)
								{
									lastDay=lastDay-366;
									calendar.set(Calendar.DAY_OF_YEAR,lastDay);
									calendar.set(Calendar.YEAR, arrival_yr+1);
								}
								else
								{
									calendar.set(Calendar.DAY_OF_YEAR,lastDay);
									calendar.set(Calendar.YEAR, arrival_yr);
								}
							}
							else
							{
								if(lastDay>365)
								{
								lastDay=lastDay-365;
								calendar.set(Calendar.DAY_OF_YEAR,lastDay);
								calendar.set(Calendar.YEAR, arrival_yr+1);
								}
								else
								{
									calendar.set(Calendar.DAY_OF_YEAR,lastDay);
									calendar.set(Calendar.YEAR, arrival_yr);
								}
							}
							
							Date lastDayDate_cust=calendar.getTime();
							System.out.println("Last day of customer :"+lastDay);
							String gac_Aufenthaltsdauer1 = format1.format( calendar.getTime());

							System.out.println("Guest's Arrival Date= "+gac_Anreise);
							
							System.out.println("Guest's Arrival Day= " +dayOfYear);
							System.out.println("Guest's Departure Day= "+lastDay);
							System.out.println("Guest's Stay Days= "+gac_Aufenthaltsdauer);
					
						
							
							// Output Current Date (Heutige Datum) 
							
							Date date=new Date();
							
							String todayDate = format1.format(date);

							System.out.println("Today's Date= "+date);
							

							li=ad.getLeistungsFreigabe(idGastCardType,idLeistung);
							
							// Current Day is which day of the year
							
							Calendar calendar4 = Calendar.getInstance();
					    	int day = calendar4.get(Calendar.DAY_OF_WEEK);
							Calendar cal = new GregorianCalendar();
							cal.setTime(new Date()); // Give your own date
							System.out.println("Today is Day of the year= "+cal.get(Calendar.DAY_OF_YEAR));
							int todayDay=cal.get(Calendar.DAY_OF_YEAR);
							
							
							int isPre=0;
							
							if(li.size()>0)
						
								
							{
								
								Boolean servNotActive=false;
								allgs=li.get(0);
								
								int gcn_Counter=allgs.getGcn_counter();
								int perDayCnt=allgs.getRemainingServicesPerDay();
								
								System.out.println("Gcn Cnt :"+gcn_Counter);
								
								
							   
								
								String idLeistungsFreigabe=allgs.getIdLeistungsFreigabe();
//								List<Allgetset> gastCardDet=ad.getGastCardDetails(idLeistungsFreigabe, idLeistung);
								 if (ad.chkPre(carNo.substring(0,4)))
								 {
									 isPre=1;
									 
							// Limitation current date <= EndDatum in dbo.GastCardTyp   Prepaid cards
									
								 
//								Date d;
								try {
//									d = format1.parse(endDate);
									
									 SimpleDateFormat in = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
									    SimpleDateFormat out = new SimpleDateFormat("dd-MM-yy HH:mm:ss");

									    Date d = in.parse(endDate);
//									    String result = out.format(date);
//									    System.out.println(result);
									
									
									cal.setTime(d); 
									System.out.println("End Day of validity= "+cal.get(Calendar.DAY_OF_YEAR));
									int endDatumDay=cal.get(Calendar.DAY_OF_YEAR);
									
									
									if(!(new Date().compareTo(d)<=0))
									{
										servNotActive=true;
										System.out.println("error msg");
									}
									
									
									// Limitation on uses Per Stay and Per Day Prepaid cards // 0151102467810770010509 
									
									else if(allgs.getGcn_counter()<allgs.getLef_NutzungsAnzahl())
									{
										System.out.println("Inside allgs.getGcn_counter()<allgs.getLef_NutzungsAnzahl()");
										gcn_Counter++;
										

										if(allgs.getLef_EinmalProTag())
										{
											if(new Date().compareTo(allgs.getGcn_TimeStamp())==0)
											{
												if(allgs.getRemainingServicesPerDay()==0)
												{
													perDayCnt=1;
												}
												else
												{
													System.out.println("Inside EnimalProTag");
													System.out.println("Already used for today");
													perDayCnt=allgs.getRemainingServicesPerDay();
													servNotActive=true;
													
//													session.removeAttribute("notactive");
													session.setAttribute("notactive", "Nutzungs-Limit wurde erreicht!");
												}
											}
											else
											{
											perDayCnt=1;
											}
										}
										else if(!allgs.getLef_EinmalProTag())
										{
											System.out.println("Service  per Day limit exceed / Nutzungs-Limit wurde erreicht!");
											perDayCnt=allgs.getRemainingServicesPerDay();
											servNotActive=true;
//											session.removeAttribute("notactive");
											session.setAttribute("notactive", "Nutzungs-Limit wurde erreicht!");
										}
									}
									
									else if(allgs.getGcn_counter()==allgs.getLef_NutzungsAnzahl())
									{
										System.out.println("Inside allgs.getGcn_counter()==allgs.getLef_NutzungsAnzahl()");

										servNotActive=true;
//										session.removeAttribute("notactive");
										session.setAttribute("notactive", "Nutzungs-Limit wurde erreicht!");
										System.out.println("Service per Stay limit exceed / Nutzungs-Limit wurde erreicht!");
										gcn_Counter=allgs.getLef_NutzungsAnzahl();
										perDayCnt=allgs.getRemainingServicesPerDay();
									}
									else if(allgs.getGcn_counter()==0)
									{
										servNotActive=true;
//										session.removeAttribute("notactive");
										session.setAttribute("notactive", "Nutzungs-Limit wurde erreicht!");
									}
									
									
									
									// Limitation on Weekdays Prepaid cards
									
									
									else if(allgs.getLef_Wochentage()!=0)
									{
										if(allgs.getLef_Wochentage()==day)
										{
											
											System.out.println("cannot able to use on"+day+" of week");
											servNotActive=true;
//											session.removeAttribute("notactive");
											session.setAttribute("notactive", "cannot able to use on"+day+" of week");
										}
									}
									
									
								// Limitation on 3 types of prepaid card 
									
									else if(gastDetails.size()!=0)
									{	Calendar c = Calendar.getInstance(); 
									c.setTime(gastDetails.get(0).getGac_TimeStamp()); 
									c.add(Calendar.DATE, withinDays);
										if(!(gastDetails.get(0).getGac_TimeStamp().compareTo(c.getTime())<0))
										{
											servNotActive=true;
//											session.removeAttribute("notactive");
											session.setAttribute("notactive", "NotActive");
										if(!(gastDetails.size()<usableDays))
										{
//											session.removeAttribute("notactive");
											session.setAttribute("notactive", "NotActive");

										}
										
										
										else if(gastDetails.size()==allgs.getGct_Nutzungstage())
										{
											System.out.println("cannot use");
											servNotActive=true;
//											session.removeAttribute("notactive");
											session.setAttribute("notactive", "cannot use");
										}
										}
									}
								} catch (ParseException e) {
									System.out.println("Inside catch");
									// TODO Auto-generated catch block
									e.printStackTrace();
								}
								
								
								 
								 }
								 
								 
								 
								//* Programs for Limitations of Instant cards (Meldewesen) *// 
								 
								// Program for Limitation not on arrival day (Nicht am Anreise Tag) 0150104028614170450119
								 
								 else{
								
									 System.out.println("allgs.getLef_NichtAmAnreisetag() :"+allgs.getLef_NichtAmAnreisetag());
									 System.out.println("allgs.getLef_NichtAmAbreisetag() :"+allgs.getLef_NichtAmAbreisetag());
									 if(allgs.getLef_NichtAmAnreisetag())
									 {
										 if(gac_Anreise.equals(todayDate))
										 {
											
											 //cannot use (error Limitation Anreisetag)  "Fehlermeldung"  // Instant cards
											 
											servNotActive=true;
											System.out.println("Leistung am Anreisetag nicht gültig.");
//											session.removeAttribute("notactive");
											session.setAttribute("notactive", "Leistung am Anreisetag nicht gültig.");
											 
										}
									 }
								 
								 

						
								// Program for Limitation Not on Departure Day (Nicht am Abreise Tag) Instant cards
								
				 
								else if(allgs.getLef_NichtAmAbreisetag())
									 {
									System.out.println("Inside dep Day");
										if(new Date().compareTo(lastDayDate_cust)==0)
										{
											//cannot use (error Limitation Abreisetag)  "Fehlermeldung"  // 
											servNotActive=true;
											System.out.println("Leistung am Abreisetag nicht gültig.");
//											session.removeAttribute("notactive");
											session.setAttribute("notactive", "Leistung am Abreisetag nicht gültig.");
										
											System.out.println("======*****========");
										}
									 }
									 
								// Program for Limitation Today's date in the period of stay (arrival and departure)? Instant cards
				 
								 
								else if(!(arrival_date_cust.compareTo(new Date())<0&&(new Date().compareTo(lastDayDate_cust)<0))) 
								 {
									 servNotActive=true;
										System.out.println("Karte ausserhalb des Gültigkeitszeitraums.");
//										session.removeAttribute("notactive");
										session.setAttribute("notactive", "Karte ausserhalb des Gültigkeitszeitraums.");
								}
								
					
								 
								 
								 // Program for Limitation MindestAufenthalt (Minimum Stay of Guest)  Instant cards
								 
								else if(allgs.getLef_MindestAufenthalt()>Integer.parseInt(gac_Aufenthaltsdauer))
								{
									//cannot use
									servNotActive=true;
									System.out.println("Leistung durch zu geringen MindestAufhenthalt nicht verfügbar. Sie müssen mindestens " + allgs.getLef_MindestAufenthalt()+" Tage Aufenthalten.");
//									session.removeAttribute("notactive");
									session.setAttribute("notactive", "Leistung durch zu geringen MindestAufhenthalt nicht verfügbar.");

								}
								 
								 
								// Program for limitation Anzahl Nutzungen Pro Zeitraum and Anzahl Nutzungen Pro Tag Instant cards
								 
								else if(allgs.getGcn_counter()<allgs.getLef_NutzungsAnzahl())
								{
									
									gcn_Counter++;
									
//									if(allgs.getRemainingServicesPerDay()<allgs.getLef_EinmalProTag())
//									{
//										perDayCnt++;
//									}
//									else if(allgs.getRemainingServicesPerDay()==allgs.getLef_EinmalProTag())
//									{
//										System.out.println("Service  per Day limit exceed / Nutzungs-Limit wurde erreicht!");
//										perDayCnt=allgs.getLef_EinmalProTag();
//										servNotActive=true;
//										session.setAttribute("notactive", "Nutzungs-Limit wurde erreicht!");
//									}
									
									if(allgs.getLef_EinmalProTag())
									{
										if(new Date().compareTo(allgs.getGcn_TimeStamp())==0)
										{
											if(allgs.getRemainingServicesPerDay()==0)
											{
												perDayCnt=1;
											}
											else
											{
												System.out.println("Already used for today");
												perDayCnt=allgs.getRemainingServicesPerDay();
												servNotActive=true;
//												session.removeAttribute("notactive");
												session.setAttribute("notactive", "Nutzungs-Limit wurde erreicht!");
											}
										}
										else
										{
										perDayCnt=1;
										}
									}
									else if(!allgs.getLef_EinmalProTag())
									{
										System.out.println("Service  per Day limit exceed / Nutzungs-Limit wurde erreicht!");
										perDayCnt=allgs.getRemainingServicesPerDay();
										servNotActive=true;
//										session.removeAttribute("notactive");
										session.setAttribute("notactive", "Nutzungs-Limit wurde erreicht!");
									}
								}
								
								else if(allgs.getGcn_counter()==allgs.getLef_NutzungsAnzahl())
								{
									servNotActive=true;
//									session.removeAttribute("notactive");
									session.setAttribute("notactive", "Nutzungs-Limit wurde erreicht!");
									System.out.println("Service per Stay limit exceed / Nutzungs-Limit wurde erreicht!");
									gcn_Counter=allgs.getLef_NutzungsAnzahl();
									perDayCnt=allgs.getRemainingServicesPerDay();
								}
								else if(allgs.getGcn_counter()==0)
								{
									servNotActive=true;
//									session.removeAttribute("notactive");
									session.setAttribute("notactive", "Nutzungs-Limit wurde erreicht!");
								}
									 
									 // Limitation for uses on Weekdays Instant cards
									 
								else if(allgs.getLef_Wochentage()!=0)
								{
									if(allgs.getLef_Wochentage()==day)
									{
										
										System.out.println("cannot able to use on"+day+" of week");
										servNotActive=true;
//										session.removeAttribute("notactive");
										session.setAttribute("notactive", "cannot able to use on"+day+" of week");
									}
								}
								 
									 
								 
								 } 
							
								 
								 // (any of the above conditions not satisfied) Display Error and Save in DB   //  
								
								if(servNotActive)
								{
									String gcn_Meldung=(String)session.getAttribute("notactive");
									try {
										ad.insertBarcodeDetails(id, idGastCardType,carNo,gac_KartenTypeCode,gac_KartenNummer,gac_Klasse,gac_Kategorie,auf,sqlDate,isPre,idLeistungsFreigabe,idLeistung,false,gcn_Meldung);
										
										ad.updateServiceDetails(allgs.getKontaktId(),idGastCardType,idLeistung,idLeistungsFreigabe,false,gcn_Meldung,gcn_Counter,perDayCnt);
									} catch (ClassNotFoundException e) {
										// TODO Auto-generated catch block
										e.printStackTrace();
									} catch (InstantiationException e) {
										// TODO Auto-generated catch block
										e.printStackTrace();
									} catch (IllegalAccessException e) {
										// TODO Auto-generated catch block
										e.printStackTrace();
									}
									System.out.println("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
//									RequestDispatcher rs = request.getRequestDispatcher("TabStartseit.jsp");
//								    rs.forward(request, response);
								}
								
//								if(servNotActive)
//								{
//									session.getAttribute("notactive");
//									
//									try {
//										ad.insertServiceDetails(id,id1,idLeistung,gcn_Gueltig,gcn_Meldung,gcn_Counter,gcn_AnzahlVerwendetNutzungenprotag);
//									} catch (ClassNotFoundException e) {
//										// TODO Auto-generated catch block
//										e.printStackTrace();
//									} catch (InstantiationException e) {
//										// TODO Auto-generated catch block
//										e.printStackTrace();
//									} catch (IllegalAccessException e) {
//										// TODO Auto-generated catch block
//										e.printStackTrace();
//									}
				//
//									RequestDispatcher rs = request.getRequestDispatcher("ServiceMes.jsp");
//								    rs.forward(request, response);
//								
//								}
					
								
								 // (All conditions satisfied) Display Success and Save in DB   //  
								else  
								{
//									session.removeAttribute("active");
									session.setAttribute("active", "Leistung gewähren!");
									String msgActive="Leistung gewähren!";
									
									try 
									{
										ad.insertBarcodeDetails(id, idGastCardType,carNo,gac_KartenTypeCode,gac_KartenNummer,gac_Klasse,gac_Kategorie,auf,sqlDate,isPre,idLeistungsFreigabe,idLeistung,true,(String)session.getAttribute("active"));
										ad.updateServiceDetails(allgs.getKontaktId(),idGastCardType,idLeistung,idLeistungsFreigabe,false,msgActive,gcn_Counter,perDayCnt);
									} catch (ClassNotFoundException e) {
										// TODO Auto-generated catch block
										e.printStackTrace();
									} catch (InstantiationException e) {
										// TODO Auto-generated catch block
										e.printStackTrace();
									} catch (IllegalAccessException e) {
										// TODO Auto-generated catch block
										e.printStackTrace();
									}
									System.out.println("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
//									RequestDispatcher rs = request.getRequestDispatcher("TabStartseit.jsp");
//								    rs.forward(request, response);
								
								}
								
							}
							
						}
						
						
						} 
						catch (SQLException e) 
						{
							// TODO Auto-generated catch block
							e.printStackTrace();
						}

					
					
					
					
				}
				
				
			}
			else
			{
				String name=request.getParameter("servno");
				System.out.println("ServNo :"+name);
				int i=0;
				for(Allgetset all:servList)
				{
					i++;
					if(name.equals("service"+i+""))
					{
						idLeistung=all.getIdLeistun();
					}
				}
//				Enumeration en=request.getParameterNames();
//				
//				while(en.hasMoreElements())
//				{
//					Object obj=en.nextElement();
//					String name=(String)obj;
//					System.out.println(name);
//					
//					int i=0;
//					for(Allgetset all:servList)
//					{
//						i++;
//						if(name.equals("service"+i+""))
//						{
//							idLeistung=all.getIdLeistun();
//						}
//					}
					
//				}
			}
		// instant card no: 0150104028614163490119 // 0150104028618690013659 
		// prepaid card no: 0132401000018700100119 // 0132401000018070013659 // 0132401000018670130259 // 
		
		
		
		// Separating the Barcode Digits and calculating the dates from it
		
		if(autoDisableCnt==0)
		{
		if(carNo.length()==22)
		{
			String barCode=carNo;
			
			String gac_KartenTypeCode=carNo.substring(0,7);
			System.out.println("gac_KartenTypeCode= "+gac_KartenTypeCode);
			
			String  gac_KartenNummer=carNo.substring(7,14);
			System.out.println("gac_KartenNummer= "+gac_KartenNummer);
			
			String gac_Klasse=carNo.substring(4,5);
			System.out.println("gac_Klasse= "+gac_Klasse);
			
			String gac_Kategorie=carNo.substring(5,7);
			System.out.println("gac_Kategorie= "+gac_Kategorie);
			
			String gac_Aufenthaltsdauer=carNo.substring(18,21);
			System.out.println("Days Stay= "+gac_Aufenthaltsdauer);
			int auf=Integer.parseInt(gac_Aufenthaltsdauer);
			String year=carNo.substring(14,15);
			System.out.println("Arrival year= "+year);
			
			String dayOfYear1=carNo.substring(15,18);
			System.out.println("Arrival Day of Year= "+dayOfYear1);
		
			
			// Program for recognizing Leap year 
			
			SimpleDateFormat format2 = new SimpleDateFormat("EEEE, d. MMMM y",Locale.GERMANY);
			Date date2=new Date();
			String d2 = format2.format(date2);
			System.out.println("d2 :"+d2.substring(d2.length()-4,d2.length()));
			int arrival_yr=Integer.parseInt(d2.substring(d2.length()-4,d2.length()-1).trim()+year.trim());
			year=d2.substring(d2.length()-4,d2.length());
			
			// total no of days in a year 
			
			int NoOfDays_yr=365;
			GregorianCalendar gre_cal = new GregorianCalendar();
			
			if(gre_cal.isLeapYear(arrival_yr))
			{
			    System.out.print("Given year is leap year.");
			    NoOfDays_yr=366;
			}
			

//			Calendar cal2 = Calendar.getInstance();
//			SimpleDateFormat format2 = new SimpleDateFormat("EEEE, d. MMMM y",Locale.GERMANY);
////			Date date=new Date();
//			String d2 = format2.format(01-01-2016);
//			Date date1;
//			try {
//				date1 = format2.parse(d2);
//				cal2.setTime(date1);
//				
//				int numOfDays = cal2.getActualMaximum(Calendar.DAY_OF_YEAR);
//				System.out.println("No of days"+numOfDays);
//			} catch (ParseException e1) {
//				// TODO Auto-generated catch block
//				e1.printStackTrace();
//			}
			
			
			//  calculating the dates
			
			int dayOfYear = Integer.parseInt(dayOfYear1);
			int dayOfYear_auf = Integer.parseInt(gac_Aufenthaltsdauer);
			int lastDay=dayOfYear+dayOfYear_auf;
	        Calendar calendar = Calendar.getInstance();
	        calendar.set(Calendar.DAY_OF_YEAR, dayOfYear);
	        calendar.set(Calendar.YEAR, arrival_yr);
	        System.out.println("Guest's Arrival Day= " + dayOfYear );
	        Date arrival_date_cust=calendar.getTime();
	      
	        System.out.println("Arrival Date of Guest :"+arrival_date_cust);
			SimpleDateFormat format1 = new SimpleDateFormat("EEEE, d. MMMM y",Locale.GERMANY);
			System.out.println("Guest's Arrival Date= " + calendar.getTime());
			System.out.println();
			java.util.Date utilDate = (arrival_date_cust);
					SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
					final String stringDate= dateFormat.format(utilDate);
					final java.sql.Date sqlDate=  java.sql.Date.valueOf(stringDate);
			
			// Output Guest's Arrival & Departure day

			String gac_Anreise = format1.format( calendar.getTime());
//			  java.util.Date myDate = new java.util.Date(format1.format(gac_Anreise));
//				 java.sql.Date sqlDate = new java.sql.Date(myDate.getTime());
//			
				
			 
			if(NoOfDays_yr==366)
			{
				if(lastDay>366)
				{
					lastDay=lastDay-366;
					calendar.set(Calendar.DAY_OF_YEAR,lastDay);
					calendar.set(Calendar.YEAR, arrival_yr+1);
				}
				else
				{
					calendar.set(Calendar.DAY_OF_YEAR,lastDay);
					calendar.set(Calendar.YEAR, arrival_yr);
				}
			}
			else
			{
				if(lastDay>365)
				{
				lastDay=lastDay-365;
				calendar.set(Calendar.DAY_OF_YEAR,lastDay);
				calendar.set(Calendar.YEAR, arrival_yr+1);
				}
				else
				{
					calendar.set(Calendar.DAY_OF_YEAR,lastDay);
					calendar.set(Calendar.YEAR, arrival_yr);
				}
			}
			
			Date lastDayDate_cust=calendar.getTime();
			System.out.println("Last day of customer :"+lastDay);
			String gac_Aufenthaltsdauer1 = format1.format( calendar.getTime());

			System.out.println("Guest's Arrival Date= "+gac_Anreise);
			
			System.out.println("Guest's Arrival Day= " +dayOfYear);
			System.out.println("Guest's Departure Day= "+lastDay);
			System.out.println("Guest's Stay Days= "+gac_Aufenthaltsdauer);
	
		
			
			// Output Current Date (Heutige Datum) 
			
			Date date=new Date();
			
			String todayDate = format1.format(date);

			System.out.println("Today's Date= "+date);
			

			li=ad.getLeistungsFreigabe(idGastCardType,idLeistung);
			
			// Current Day is which day of the year
			
			Calendar calendar4 = Calendar.getInstance();
	    	int day = calendar4.get(Calendar.DAY_OF_WEEK);
			Calendar cal = new GregorianCalendar();
			cal.setTime(new Date()); // Give your own date
			System.out.println("Today is Day of the year= "+cal.get(Calendar.DAY_OF_YEAR));
			int todayDay=cal.get(Calendar.DAY_OF_YEAR);
			
			
			int isPre=0;
			
			if(li.size()>0)
		
				
			{
				
				Boolean servNotActive=false;
				allgs=li.get(0);
				
				int gcn_Counter=allgs.getGcn_counter();
				int perDayCnt=allgs.getRemainingServicesPerDay();
				
				System.out.println("Gcn Cnt :"+gcn_Counter);
				
				
			   
				
				String idLeistungsFreigabe=allgs.getIdLeistungsFreigabe();
//				List<Allgetset> gastCardDet=ad.getGastCardDetails(idLeistungsFreigabe, idLeistung);
				 if (ad.chkPre(carNo.substring(0,4)))
				 {
					 isPre=1;
					 
			// Limitation current date <= EndDatum in dbo.GastCardTyp   Prepaid cards
					
				 
//				Date d;
				try {
//					d = format1.parse(endDate);
					
					 SimpleDateFormat in = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
					    SimpleDateFormat out = new SimpleDateFormat("dd-MM-yy HH:mm:ss");

					    Date d = in.parse(endDate);
//					    String result = out.format(date);
//					    System.out.println(result);
					
					
					cal.setTime(d); 
					System.out.println("End Day of validity= "+cal.get(Calendar.DAY_OF_YEAR));
					int endDatumDay=cal.get(Calendar.DAY_OF_YEAR);
					
					
					if(!(new Date().compareTo(d)<=0))
					{
						servNotActive=true;
						System.out.println("error msg");
					}
					
					
					// Limitation on uses Per Stay and Per Day Prepaid cards // 0151102467810770010509 
					
					else if(allgs.getGcn_counter()<allgs.getLef_NutzungsAnzahl())
					{
						System.out.println("Inside allgs.getGcn_counter()<allgs.getLef_NutzungsAnzahl()");
						gcn_Counter++;
						
//						if(allgs.getRemainingServicesPerDay()<allgs.getLef_EinmalProTag())
//						{
//							perDayCnt++;
//						}
//						else if(allgs.getRemainingServicesPerDay()==allgs.getLef_EinmalProTag())
//						{
//							System.out.println("Service  per Day limit exceed / Nutzungs-Limit wurde erreicht!");
//							perDayCnt=allgs.getLef_EinmalProTag();
//							servNotActive=true;
//							session.setAttribute("notactive", "Nutzungs-Limit wurde erreicht!");
//						}
						if(allgs.getLef_EinmalProTag())
						{
							if(new Date().compareTo(allgs.getGcn_TimeStamp())==0)
							{
								if(allgs.getRemainingServicesPerDay()==0)
								{
									perDayCnt=1;
								}
								else
								{
									System.out.println("Inside EnimalProTag");
									System.out.println("Already used for today");
									perDayCnt=allgs.getRemainingServicesPerDay();
									servNotActive=true;
//									session.removeAttribute("notactive");
									session.setAttribute("notactive", "Nutzungs-Limit wurde erreicht!");
								}
							}
							else
							{
							perDayCnt=1;
							}
						}
						else if(!allgs.getLef_EinmalProTag())
						{
							System.out.println("Service  per Day limit exceed / Nutzungs-Limit wurde erreicht!");
							perDayCnt=allgs.getRemainingServicesPerDay();
							servNotActive=true;
//							session.removeAttribute("notactive");
							session.setAttribute("notactive", "Nutzungs-Limit wurde erreicht!");
						}
					}
					
					else if(allgs.getGcn_counter()==allgs.getLef_NutzungsAnzahl())
					{
						System.out.println("Inside allgs.getGcn_counter()==allgs.getLef_NutzungsAnzahl()");

						servNotActive=true;
//						session.removeAttribute("notactive");
						session.setAttribute("notactive", "Nutzungs-Limit wurde erreicht!");
						System.out.println("Service per Stay limit exceed / Nutzungs-Limit wurde erreicht!");
						gcn_Counter=allgs.getLef_NutzungsAnzahl();
						perDayCnt=allgs.getRemainingServicesPerDay();
					}
					else if(allgs.getGcn_counter()==0)
					{
						servNotActive=true;
//						session.removeAttribute("notactive");
						session.setAttribute("notactive", "Nutzungs-Limit wurde erreicht!");
					}
					
					
					
					// Limitation on Weekdays Prepaid cards
					
					
					else if(allgs.getLef_Wochentage()!=0)
					{
						if(allgs.getLef_Wochentage()==day)
						{
							
							System.out.println("cannot able to use on"+day+" of week");
							servNotActive=true;
//							session.removeAttribute("notactive");
							session.setAttribute("notactive", "cannot able to use on"+day+" of week");
						}
					}
					
					
				// Limitation on 3 types of prepaid card 
					
					else if(gastDetails.size()!=0)
					{	Calendar c = Calendar.getInstance(); 
					c.setTime(gastDetails.get(0).getGac_TimeStamp()); 
					c.add(Calendar.DATE, withinDays);
						if(!(gastDetails.get(0).getGac_TimeStamp().compareTo(c.getTime())<0))
						{
							servNotActive=true;
//							session.removeAttribute("notactive");
							session.setAttribute("notactive", "NotActive");
						if(!(gastDetails.size()<usableDays))
						{
//							session.removeAttribute("notactive");
							
							session.setAttribute("notactive", "NotActive");
//							try {
//								ad.insertBarcodeDetails(id, idGastCardType,carNo,gac_KartenTypeCode,gac_KartenNummer,gac_Klasse,gac_Kategorie,auf,sqlDate,isPre,idLeistungsFreigabe,idLeistung,false,(String)session.getAttribute("active"));
//							} catch (ClassNotFoundException e) {
//								// TODO Auto-generated catch block
//								e.printStackTrace();
//							} catch (InstantiationException e) {
//								// TODO Auto-generated catch block
//								e.printStackTrace();
//							} catch (IllegalAccessException e) {
//								// TODO Auto-generated catch block
//								e.printStackTrace();
//							}
						}
						
						
						else if(gastDetails.size()==allgs.getGct_Nutzungstage())
						{
							System.out.println("cannot use");
							servNotActive=true;
//							session.removeAttribute("notactive");
							session.setAttribute("notactive", "cannot use");
						}
						}
					}
				} catch (ParseException e) {
					System.out.println("Inside catch");
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
				
				 
				 }
				 
				 
				 
				//* Programs for Limitations of Instant cards (Meldewesen) *// 
				 
				// Program for Limitation not on arrival day (Nicht am Anreise Tag) 0150104028614170450119
				 
				 else{
				
					 System.out.println("allgs.getLef_NichtAmAnreisetag() :"+allgs.getLef_NichtAmAnreisetag());
					 System.out.println("allgs.getLef_NichtAmAbreisetag() :"+allgs.getLef_NichtAmAbreisetag());
					 if(allgs.getLef_NichtAmAnreisetag())
					 {
						 if(gac_Anreise.equals(todayDate))
						 {
							
							 //cannot use (error Limitation Anreisetag)  "Fehlermeldung"  // Instant cards
							 
							servNotActive=true;
							System.out.println("Leistung am Anreisetag nicht gültig.");
//							session.removeAttribute("notactive");
							session.setAttribute("notactive", "Leistung am Anreisetag nicht gültig.");
							 
						}
					 }
				 
				 

		
				// Program for Limitation Not on Departure Day (Nicht am Abreise Tag) Instant cards
				
 
				else if(allgs.getLef_NichtAmAbreisetag())
					 {
					System.out.println("Inside dep Day");
						if(new Date().compareTo(lastDayDate_cust)==0)
						{
							//cannot use (error Limitation Abreisetag)  "Fehlermeldung"  // 
							servNotActive=true;
							System.out.println("Leistung am Abreisetag nicht gültig.");
//							session.removeAttribute("notactive");
							session.setAttribute("notactive", "Leistung am Abreisetag nicht gültig.");
						
							System.out.println("======*****========");
						}
					 }
					 
				// Program for Limitation Today's date in the period of stay (arrival and departure)? Instant cards
 
				 
				else if(!(arrival_date_cust.compareTo(new Date())<0&&(new Date().compareTo(lastDayDate_cust)<0))) 
				 {
					 servNotActive=true;
						System.out.println("Karte ausserhalb des Gültigkeitszeitraums.");
//						session.removeAttribute("notactive");
						session.setAttribute("notactive", "Karte ausserhalb des Gültigkeitszeitraums.");
				}
				
	
				 
				 
				 // Program for Limitation MindestAufenthalt (Minimum Stay of Guest)  Instant cards
				 
				else if(allgs.getLef_MindestAufenthalt()>Integer.parseInt(gac_Aufenthaltsdauer))
				{
					//cannot use
					servNotActive=true;
					System.out.println("Leistung durch zu geringen MindestAufhenthalt nicht verfügbar. Sie müssen mindestens " + allgs.getLef_MindestAufenthalt()+" Tage Aufenthalten.");
//					session.removeAttribute("notactive");
					session.setAttribute("notactive", "Leistung durch zu geringen MindestAufhenthalt nicht verfügbar.");

				}
				 
				 
				// Program for limitation Anzahl Nutzungen Pro Zeitraum and Anzahl Nutzungen Pro Tag Instant cards
				 
				else if(allgs.getGcn_counter()<allgs.getLef_NutzungsAnzahl())
				{
					
					gcn_Counter++;
					
//					if(allgs.getRemainingServicesPerDay()<allgs.getLef_EinmalProTag())
//					{
//						perDayCnt++;
//					}
//					else if(allgs.getRemainingServicesPerDay()==allgs.getLef_EinmalProTag())
//					{
//						System.out.println("Service  per Day limit exceed / Nutzungs-Limit wurde erreicht!");
//						perDayCnt=allgs.getLef_EinmalProTag();
//						servNotActive=true;
//						session.setAttribute("notactive", "Nutzungs-Limit wurde erreicht!");
//					}
					
					if(allgs.getLef_EinmalProTag())
					{
						System.out.println("DAteeeeeeeee eerrrrrror"+(allgs.getGcn_TimeStamp()));
						if(new Date().compareTo(allgs.getGcn_TimeStamp())==0)
						{
							if(allgs.getRemainingServicesPerDay()==0)
							{
								perDayCnt=1;
							}
							else
							{
								System.out.println("Already used for today");
								perDayCnt=allgs.getRemainingServicesPerDay();
								servNotActive=true;
//								session.removeAttribute("notactive");
								session.setAttribute("notactive", "Nutzungs-Limit wurde erreicht!");
							}
						}
						else
						{
						perDayCnt=1;
						}
					}
					else if(!allgs.getLef_EinmalProTag())
					{
						System.out.println("Service  per Day limit exceed / Nutzungs-Limit wurde erreicht!");
						perDayCnt=allgs.getRemainingServicesPerDay();
						servNotActive=true;
//						session.removeAttribute("notactive");
						session.setAttribute("notactive", "Nutzungs-Limit wurde erreicht!");
					}
				}
				
				else if(allgs.getGcn_counter()==allgs.getLef_NutzungsAnzahl())
				{
					servNotActive=true;
//					session.removeAttribute("notactive");
					session.setAttribute("notactive", "Nutzungs-Limit wurde erreicht!");
					System.out.println("Service per Stay limit exceed / Nutzungs-Limit wurde erreicht!");
					gcn_Counter=allgs.getLef_NutzungsAnzahl();
					perDayCnt=allgs.getRemainingServicesPerDay();
				}
				else if(allgs.getGcn_counter()==0)
				{
					servNotActive=true;
//					session.removeAttribute("notactive");
					session.setAttribute("notactive", "Nutzungs-Limit wurde erreicht!");
				}
					 
					 // Limitation for uses on Weekdays Instant cards
					 
				else if(allgs.getLef_Wochentage()!=0)
				{
					if(allgs.getLef_Wochentage()==day)
					{
						
						System.out.println("cannot able to use on"+day+" of week");
						servNotActive=true;
//						session.removeAttribute("notactive");
						session.setAttribute("notactive", "cannot able to use on"+day+" of week");
					}
				}
				 
					 
				 
				 } 
			
				 
				 // (any of the above conditions not satisfied) Display Error and Save in DB   //  
				
				if(servNotActive)
				{
//					session.removeAttribute("disable");
					session.setAttribute("disable", "disabled=disabled");
					String gcn_Meldung=(String)session.getAttribute("notactive");
					try {
						ad.insertBarcodeDetails(id, idGastCardType,carNo,gac_KartenTypeCode,gac_KartenNummer,gac_Klasse,gac_Kategorie,auf,sqlDate,isPre,idLeistungsFreigabe,idLeistung,false,gcn_Meldung);
						
						ad.updateServiceDetails(allgs.getKontaktId(),idGastCardType,idLeistung,idLeistungsFreigabe,false,gcn_Meldung,gcn_Counter,perDayCnt);
					} catch (ClassNotFoundException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					} catch (InstantiationException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					} catch (IllegalAccessException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
					System.out.println("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
//					RequestDispatcher rs = request.getRequestDispatcher("TabStartseit.jsp");
//				    rs.forward(request, response);
				}
				
//				if(servNotActive)
//				{
//					session.getAttribute("notactive");
//					
//					try {
//						ad.insertServiceDetails(id,id1,idLeistung,gcn_Gueltig,gcn_Meldung,gcn_Counter,gcn_AnzahlVerwendetNutzungenprotag);
//					} catch (ClassNotFoundException e) {
//						// TODO Auto-generated catch block
//						e.printStackTrace();
//					} catch (InstantiationException e) {
//						// TODO Auto-generated catch block
//						e.printStackTrace();
//					} catch (IllegalAccessException e) {
//						// TODO Auto-generated catch block
//						e.printStackTrace();
//					}
//
//					RequestDispatcher rs = request.getRequestDispatcher("ServiceMes.jsp");
//				    rs.forward(request, response);
//				
//				}
	
				
				 // (All conditions satisfied) Display Success and Save in DB   //  
				else  
				{
//					session.removeAttribute("active");
					session.setAttribute("active", "Leistung gewähren!");
					String msgActive="Leistung gewähren!";
					
					try 
					{
						ad.insertBarcodeDetails(id, idGastCardType,carNo,gac_KartenTypeCode,gac_KartenNummer,gac_Klasse,gac_Kategorie,auf,sqlDate,isPre,idLeistungsFreigabe,idLeistung,true,(String)session.getAttribute("active"));
						ad.updateServiceDetails(allgs.getKontaktId(),idGastCardType,idLeistung,idLeistungsFreigabe,false,msgActive,gcn_Counter,perDayCnt);
					} catch (ClassNotFoundException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					} catch (InstantiationException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					} catch (IllegalAccessException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
					System.out.println("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
//					RequestDispatcher rs = request.getRequestDispatcher("TabStartseit.jsp");
//				    rs.forward(request, response);
				
				}
				
			}
			
		}
		}
		
		
		} 
		catch (SQLException e) 
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	
	}

}


Мой jsp:
<pre><%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ page import="java.io.*,java.util.*, javax.servlet.*" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page import="java.io.*,java.util.Locale" %>
<%@ page import="javax.servlet.*,javax.servlet.http.* "%>
<%@ page import="java.text.DateFormat,java.util.Date" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>  
<%@ page import="java.io.*,java.util.*,java.sql.*"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<%@ page session="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="de">
<head>
  <title>Online-Terminal  </title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <link rel="shortcut icon" type="image/x-icon" href="images/Favicon_BWM.ico">
  <link rel="stylesheet" href="css/Style.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  
  
  <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
  <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
 
  
  <script src="http://code.jquery.com/jquery-latest.min.js"></script>
  <script src="js/jquery-1.11.1.js" type="text/javascript"></script>
  <script type="text/javascript" src="ajax.js"></script>
  <script src="js/sorttable.js"></script>
  
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
  <link rel="stylesheet" href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css">
<!--   <script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script> -->
 
 <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
 <script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>
 <script src="https://cdn.datatables.net/1.10.13/js/dataTables.bootstrap.min.js"></script>
 <script src="https://cdn.datatables.net/buttons/1.2.4/js/dataTables.buttons.min.js"></script>
 <script src="https://cdn.datatables.net/buttons/1.2.4/js/buttons.bootstrap.min.js"></script>
 <script src="//cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min.js"></script>
 <script src="//cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/pdfmake.min.js"></script>
 <script src="//cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/vfs_fonts.js"></script>
 <script src="//cdn.datatables.net/buttons/1.2.4/js/buttons.html5.min.js"></script>
 <script src="//cdn.datatables.net/buttons/1.2.4/js/buttons.print.min.js"></script>
 <script src="//cdn.datatables.net/buttons/1.2.4/js/buttons.colVis.min.js"></script>
 <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
 <link rel="stylesheet" href="/resources/demos/style.css">
 <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>  
 <script src="js/filter.js"></script>
 <script src="js/column.js"></script>
  
  

  




<!-- ******************************* STATISTICS DATATABLE ************************************** -->
 
<!--  ******************************* DATEPICKER  *************************** -->

<script>
  $( function() {
    $( "#startDate" ).datepicker();
  } );
</script>
<script>
  $( function() {
    $( "#tst" ).datepicker();
  } );
</script>


 
<script type="text/javascript">
      
  $(document).ready(function() {
	    var table = $('#example').DataTable( {
	    	
              
	        
			dom: 'Blfrtip',

	        buttons: [ {
                /* extend: 'print',
                exportOptions: {
                    columns: ':visible'
                }
            },
            
            
            'copy', 'excel', 'pdf' */
            
            extend: 'collection',
            text: 'Export ' ,
            buttons: [
                'copy',
                'excel',
                'pdf',
                'print'
	    
            
            ],
	    }],
	    "language": {
            "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/German.json"},
	    
	    } );
	 
	    table.buttons().container()
	        .appendTo( '#example_wrapper .col-sm-6:eq(0)' );
	    
	} ); 
 
 
 /* $('#example').DataTable({
     "iDisplayLength": 20,
     "aLengthMenu": [[10, 20, 50, -1], [10, 20, 50, "All"]],
     "pagingType": "simple_numbers",
     "language": {
         searchPlaceholder: "Search",
         search: "",

     },
     "dom": '<"top"f>rt<"bottom"ilp><"clear">'
 }); */
 
 /* $(document).ready(function() {
	    $('#example').DataTable( {
	        "dom": '<"top"i>rt<"bottom"flp><"clear">'
	    } );
	} ); */
 
 
 /* $(document).ready(function() {
	    $('#example').dataTable( {
	        // Sets the row-num-selection "Show %n entries" for the user
	        "lengthMenu": [ 10,20, 40, 60, 80, 100 ], 
	        
	        // Set the default no. of rows to display
	        "pageLength": 20 
	    } );
	} ); */
</script>
      

<script type="text/javascript">
$(document).ready(function() {
	    // Setup - add a text input to each footer cell
	    $('#example tfoot th').each( function () {
	        var title = $(this).text();
	        $(this).html( '<input type="text" placeholder="Search '+title+'" />' );
	    } );
	 
	    // DataTable
	    var table = $('#example').DataTable();
	 
	    // Apply the search
	    table.columns().every( function () {
	        var that = this;
	 
	        $( 'input', this.footer() ).on( 'keyup change', function () {
	            if ( that.search() !== this.value ) {
	                that
	                    .search( this.value )
	                    .draw();
	            }
	        } );
	    } );
	} );

</script>

   


      
<!--    ************************* VALIDITY ************************* -->

<script type="text/javascript">

 $(document).ready(function() {
	
     $('#preview').click(function(event) {
    	 $("#chkcomments").load("statblock.jsp");
    	 $('#div3').text("");
             var name = $('#Kartennummer').val();
             $.post('GultigkartenServlet', {
           	  Kartennummer : name
             }, function(responseText) {
            	 if(responseText == 'Unbekannte Karte') {
            		 document.getElementById('cardDetDiv').style.visibility = 'hidden';
            		 
            		 $('#div3').text(responseText);
           		
                 } 
            	 else
            		 
            		 document.getElementById('cardDetDiv').style.visibility = 'visible';
//             	     document.getElementById('div1').style.backgroundColor = 'red';
                     $('#div2').text(responseText.substring(0,21));
                     $('#div1').text(responseText.substring(21,responseText.length));
                    
             });
     });
});
 
 
 $(document).ready(function()
		  {
		      $('#Kartennummer').click(function(){  
		           
		               $(this).val(''); 
		           
		      })
		  })
		  
		  
</script>

<!--     ************************************************ DATE FILTER *************************************************** -->

<script type="text/javascript">
$(document).ready(function(){
$('#pre').click(function(event) {
    	 
    	 var stdate = $('#startDate').val();
    	 var type=$( "#myselect" ).val();
    	 var test = $('#tst').val();
    	 
    	 
    	 $.post('DateSet', {
    		 startDate : stdate,
    		 filterType : type,
    		 tst : test
    		
         });
    	 location.reload();
     });
     
});
</script>


<!--     ************************************************ SERVICES *************************************************** -->


<script type="text/javascript">

$(document).ready(function(){
    $("button").click(function(){
        $("#div1").load("demo_test.txt");
    });
});
</script>



<script type="text/javascript">


 
 $(document).ready(function() {
	
     $('#preview2').click(function(event) {
    	 
             var cno = $('#cardnumber').val();
             $.post('DigitRef', {
            	 cardnumber : cno
             });
             
//              window.location.href = window.location.href;
//              window.location.replace(window.location);
              //location.reload(true);
		
     });
     

     
     $('#service1').click(function(event) {
    	 
    	
    	 
         var btn = $('#service1').attr("name");
         $.post('Leis1', {
        	 servno:btn
        	 
         });
         
       
//          window.location.href = window.location.href;
//          window.location.replace(window.location);
//          location.reload();
         
 });
     
    
 $('#service3').click(function(event) {
	 
	
	 
         var btn = $('#service3').attr("name");
         $.post('Leis1', {
        	 servno:btn
         });
         
//          window.location.href = window.location.href;
//          window.location.replace(window.location);
//          location.reload();
         
 });
 
 $('#service2').click(function(event) {
	 
	 
	 
     var btn = $('#service2').attr("name");
     $.post('Leis1', {
    	 servno:btn
     });
     
//      window.location.href = window.location.href;
//      window.location.replace(window.location);
//      location.reload();
     
});
     
     
});
 

</script>

<script>

function ClearFields() {

    document.getElementById("cardnumber").value = "";
    document.getElementById("Kartennummer").value = "";
    document.getElementById("startDate").value = "";
    document.getElementById("tst").value = "";
    document.getElementById("myselect").value = "";
    
    
}


function displaycover() {
    
    var x = document.getElementById('cover1');
    var y = document.getElementById('cover2');
    var z = document.getElementById('Stat');
    
    if (x.style.display === 'none') {
        x.style.display = 'block';
    } else {
        x.style.display = 'none';
    }
    
    if (y.style.display === 'none') {
    	 y.style.display = 'block';
	} else {
    	y.style.display = 'none';
	}
    
    
    if (z.style.display === 'none') {
        z.style.display = 'block';
    } else {
        z.style.display = 'none';
    }
}
</script>


<!-- <script>
function setCookie(cname,cvalue,exdays)
{
var d = new Date();
d.setTime(d.getTime()+(exdays*24*60*60*1000));
var expires = "expires="+d.toGMTString();
document.cookie = cname + "=" + cvalue + "; " + expires;
}

function getCookie(cname)
{
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++)
  {
  var c = ca[i].trim();
  if (c.indexOf(name)==0) return c.substring(name.length,c.length);
}
return "";
}

function checkCookie()
{
var user=getCookie("Benutzername");
if (user!="")
  {

  return user;
  }
else
  {
  return false; 

  }
}

jQuery(document).ready(function(){
    if(checkCookie()){
        $( "#tabs" ).tabs({ active: checkCookie() });
    }else{
        $( "#tabs" ).tabs({ active: 0 });
    }
    jQuery("#tabs ul li a").click(function(){
        var status = jQuery(this).attr("href");       
        setCookie("Benutzername",parseInt(status.replace("#fragment-",""))-1,365);
   
    });
   

});
</script>
 -->


<!-- ************************************** TAB VIEW SCRIPT *****************************************************-->
<script>
$(document).ready(function(){
    $(".nav-tabs a").click(function(){
        $(this).tab('show');
    });
});
</script> 

<script>
/* $('#tab').on('click', '.nav a', function (e) {
    clickEvent = true;
    $('.nav li').removeClass('active');
    $(this).parent().addClass('active');

    localStorage.setItem('slide', $(e.currentTarget).attr('href'));
});

$(function() {
  var slide = localStorage.getItem('slide');
  if (slide) {
    $("a[href='" + slide + "']").click();
  }
}); */


/* $(document).ready(function() {
	  var slide = window.location.hash;
	  if (slide) {
	    $("a[href='" + slide + "']").click();
	  }
	}); */

</script>
<script>


/* $(document).ready(function() {
    var $hash = window.location.hash;
    var $acc = $hash ? $hash : 1;
    $("#myTabs").tab({
     active: false,
     collapsible: true,
     autoHeight: false,
     navigation: true,
     header: '.menuitem',
     activate: $acc
   });
});  
 */
 

</script>



  <script> 
 <%

//Get the client's Locale
Locale locale = request.getLocale( );
String date = DateFormat.getDateTimeInstance(
                              DateFormat.FULL, 
                              DateFormat.SHORT, 
                              locale).format(new Date( ));
%>
</script>


<script type="text/javascript">
$(document).ready(function() {
	 $("#cover1").hide(0); 
	 $("#cover2").hide(0); 
	 $("#cover3").hide(0); 
	
  
});

</script>

<script>
   
        function expand(param)   
        {   
            param.style.display=(param.style.display=="none")?"":"none";   
        }   
    
</script>


<script type="text/javascript">

</script>

</head>

<!-- **************************** GET DATA FROM DATABASE FOR STATISTIC ****************************************** -->

<sql:setDataSource var="bwm_GastCard" driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"
     url="jdbc:sqlserver://81.20.82.195:2433;DatabaseName=bwm_GastCard"
     user="sa"  password="4xf18bw111a"/>
<sql:query dataSource="${bwm_GastCard}" var="rs2">
SELECT  gac_Barcode,gac_TimeStamp,gct_KartenType,lea_Leistungsart 
     FROM GastCard 
     INNER JOIN GastCardTyp
     ON GastCard.idGastCardType = GastCardTyp.idGastCardType 
 
     INNER JOIN Leistung
     ON GastCard.idLeistung = Leistung.idLeistung where (GastCard.
                    

0 Ответов