Win a copy of Spring in Action (5th edition) this week in the Spring forum!

hkumar patel

Greenhorn
+ Follow
since Jul 26, 2017
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by hkumar patel

how do i create jsp page ??
i used import statement where my bean class is there and i called another class and its method where database and resultset stuff is there.
11 months ago
JSP
<!DOCTYPE html>
<html>
   <head>
       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
       <title>JSP Page</title>
   

   </head>
   <body>
 
       <jsp:include page="index.jsp" />
       <form action="booking_process.jsp">
           Username:<input type='text'value=' <%=(String)session.getAttribute("theusername")%>' name="username" />
           Type:
           <input type="radio" name="trip" value="Round Trip"/> Round Trip    
           <input type="radio" name="trip" value="One Way Trip"/>One Way Trip    
           <input type="radio" name="trip" value="Multiple City Trip"/>Multiple City  
           <br>
           Source:
           <input type="text" name="Source"/><br>
           Destination:
           <input type="text" name="Destination" /><br>
           Depart Time:
           <input type="date" name="Depart" placeholder="dd/mm/yyyy"/><br>
           Arrival Time:
           <input type="date" name="Arrival" /><br>
           Class:
           <input type="text" name="class"><br>
           Passport Number:
           <input type="text" name="passport" ><br>
           Ticket Number:
           <input type="number" name="ticket"style="width:100px" value=1 min=0 max=2/><br>
           <input type="submit" value="CheckOut">
       </form>
       <br>

       
   </body>
   
</html>





<%@page import="bean.booking"%>
<jsp:useBean id="obj" class="bean.Booking_bean"/>
<jsp:setProperty name="obj" property="*" />
       <%
int i=booking.bookingTicket(obj);  
if(i>0)  {
out.print("You are successfully registered");  
}
       %>






/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package bean;

import java.sql.Date;

/**
*
* @author hardik
*/
public class Booking_bean {
   private String username;
   private String type;
   private String source;
   private String Destination;
  private Date Depart;
  private Date Arrival;
  private String classtype;
  private String Passport ;
   private int Ticket ;
   public String getUsername(){
       return username;
   }
   public void setUsername(String username){
       this.username=username;
   }
   public String getType(){
       return type;
   }
   public void setType(String type){
       this.type=type;
   }
   public Date getArrival(){
       return Arrival;
   }
   public void setArrival(Date Arrival){
       this.Arrival=Arrival;
   }
   public Date getDepart(){
       return Depart;
   }
   public void setDepart(Date Depart){
       this.Depart=Depart;
   }
   public String getSource(){
       return source;
   }
   public void setSource(String source){
       this.source=source;
   }
   public String getDestination(){
       return Destination;
   }
   public void getDestination(String Destination){
       this.Destination=Destination;
   }
   public String getClasstype(){
       return classtype;
   }
   public void setClasstype(String classtype){
       this.classtype=classtype;
   }
   public String getPassport(){
       return Passport;
   }
   public void setPassport(String Passport){
       this.Passport=Passport;
   }
   public int getTicket(){
       return Ticket;
   }
   public void setTicket(int Ticket){
       this.Ticket=Ticket;

   }
   
}

public class booking {
   public static int bookingTicket(Booking_bean bean){
       int i=0;
       try{
          Connection c=connection_provider.getCon();
    String query = "insert into ticket_book(type,source,destination,Arrival_time,depart_time,class,Passport_number,ticket_number) values(?,?,?,?,?,?,?,?)";
   PreparedStatement st = c.prepareStatement(query);
   st.setString(1,bean.getType());
   st.setString(2,bean.getSource());
   st.setString(3,bean.getDestination());
   st.setDate(4,bean.getDepart());
   st.setDate(5,bean.getArrival());
   st.setString(6,bean.getClasstype());
   st.setString(7,bean.getPassport());
   st.setInt(8,bean.getTicket());
 
  i= st.executeUpdate();
 
 }
       catch(SQLException e){
           System.out.print(e);
       }
       return i;
}
 
}
11 months ago