Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ***** home.jsp *****
- <%--
- Document : index
- Created on : Feb 27, 2015, 7:39:57 PM
- Author : OOPs
- --%>
- <%@page contentType="text/html" pageEncoding="UTF-8"%>
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <link rel="stylesheet" type="text/css" href="home.css">
- <title>Hotel Reservation</title>
- <link href="responsiveslides.css" rel="stylesheet" type="text/css"/>
- <link href="themes.css" rel="stylesheet" type="text/css"/>
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
- <script src="responsiveslides.min.js" type="text/javascript"></script>
- <style>
- @import url(css/default.css);
- </style>
- </head>
- <body>
- <div id="container">
- <div id="nav">
- <a href="home.jsp">Home</a>
- <a href="hotel.jsp">Hotel</a>
- <a href="login.jsp">Login</a>
- <a href="registration.jsp">Registrazione</a>
- <%@ include file="header.jsp" %>
- </div>
- <div> <h3>Le nostre camere:</h3></div>
- <div id="content">
- <div class="articolo">
- Camera Deluxe DOUBLE
- <br>
- DESCRIZIONE 1
- <br>
- PREZZO
- </div></div>
- <br>
- <br>
- <div id="content">
- <div class="articolo">
- Camera Deluxe SINGLE
- <br> DESCRIZIONE 2
- <br> PREZZO
- </div>
- </div>
- <br>
- <br>
- <div id="content">
- <div class="articolo">
- Camera Classic FAMILY
- <br> DESCRIZIONE 3
- <br> PREZZO
- </div>
- </div>
- <br>
- <br>
- <div id="content">
- <div class="articolo">
- Camera Classic DOUBLE
- <br> DESCRIZIONE 4
- <br> PREZZO
- </div>
- </div>
- <br>
- <br>
- <div id="content">
- <div class="articolo">
- Camera Classic SINGLE
- <br> DESCRIZIONE 5
- <br> PREZZO
- </div>
- </div>
- </div> <!-- Chiusura container -->
- </body>
- </html>
- ****** header.jsp ******
- <%--
- Document : header
- Created on : Mar 1, 2015, 2:11:38 PM
- Author : OOPs
- --%>
- <%@page contentType="text/html" pageEncoding="UTF-8"%>
- <%@ page import="java.sql.*" %>
- <% String name="";
- if(session.getAttribute("Logged-in") != null)
- {
- name = (String)session.getAttribute("name");
- }
- else
- {
- // response.sendRedirect("login.jsp");
- }
- %>
- Welcome <%= name %>
- ****** login.java ******
- /*
- * 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 hotel;
- import java.io.IOException;
- import java.io.PrintWriter;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.Statement;
- import javax.servlet.RequestDispatcher;
- import javax.servlet.ServletException;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import javax.servlet.http.HttpSession;
- /**
- *
- * @author OOPs
- */
- public class Login extends HttpServlet {
- protected void processRequest(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- response.setContentType("text/html;charset=UTF-8");
- PrintWriter out = response.getWriter();
- try {
- String s1 = request.getParameter("t1");
- String s2 = request.getParameter("t2");
- out.print("Welcome "+ s1);
- Class.forName("com.mysql.jdbc.Driver");
- out.println("driver loaded");
- Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/HotelReservation","root" ,"123456789");
- out.println("Connect");
- Statement st = con.createStatement();
- out.println("conncetion successfull");
- ResultSet rs = st.executeQuery("select email,uid, pass from register where email = '"+s1+"' and pass = '"+s2+"'");
- rs.next();
- String cid = rs.getString("uid");
- out.println("recod is inserted" +cid);
- HttpSession session=request.getSession();
- session.setAttribute("name",cid);
- // out.println("<a href=\"LoginSucess.jsp\">Check Output Page Here </a>");
- session.setAttribute("logged-in","true");
- String redirectedPage = "/parentPage";
- response.sendRedirect("loginsuccess.jsp");
- } catch (Exception e) {
- out.println("Driver not found" +e);
- }
- finally {
- out.close();
- }
- }
- // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
- /**
- * Handles the HTTP <code>GET</code> method.
- *
- * @param request servlet request
- * @param response servlet response
- * @throws ServletException if a servlet-specific error occurs
- * @throws IOException if an I/O error occurs
- */
- @Override
- protected void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- processRequest(request, response);
- }
- /**
- * Handles the HTTP <code>POST</code> method.
- *
- * @param request servlet request
- * @param response servlet response
- * @throws ServletException if a servlet-specific error occurs
- * @throws IOException if an I/O error occurs
- */
- @Override
- protected void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- processRequest(request, response);
- }
- /**
- * Returns a short description of the servlet.
- *
- * @return a String containing servlet description
- */
- @Override
- public String getServletInfo() {
- return "Short description";
- }// </editor-fold>
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement