Guest User

Untitled

a guest
Jul 22nd, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.28 KB | None | 0 0
  1. <%--
  2.     Document   : Login
  3.     Created on : Mar 27, 2012, 5:48:49 PM
  4.     Author     : mpenderg
  5. --%>
  6.  
  7. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  8. <%@page import="java.sql.*"%>
  9. <!DOCTYPE html>
  10. <html>
  11.     <head>
  12.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  13.         <title>Login</title>
  14.      <LINK rel="stylesheet" type = "text/css" href="College.css" />
  15.       <LINK rel="stylesheet" type = "text/css" href="SimpleMenu.css" />        
  16.     </head>
  17.     <body>
  18.      <script src ="Common.js"></Script>        
  19.       <div class="center">
  20.       <script src ="menu.js"></Script>
  21.         <br />
  22.         <br />        
  23.        
  24.       <%
  25.          try{
  26.           Connection con = null;
  27.           Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");  // load the driver
  28.           con = DriverManager.getConnection("jdbc:sqlserver://rubble.student.ad.fgcu.edu:1433;databaseName=sp12ism3232e;user=s12ISM3232E;password=s12ISM3232E;");
  29.          
  30.             String usercabin = request.getParameter("userlog");
  31.             String password = request.getParameter("password");
  32.            
  33.            
  34.            
  35.             PreparedStatement prep = con.prepareStatement("Select * from UserT where username = ? and password = ?");
  36.             prep.setString(1,usercabin);
  37.             prep.setString(2,password);
  38.            
  39.             ResultSet rs = prep.executeQuery();
  40.            
  41.             if(rs.next())
  42.             {
  43.                 String login = rs.getString(1);
  44.                 String pass = rs.getString(2);
  45.                 dbutility.UserLogin user = new dbutility.UserLogin(login, pass);
  46.                 session.setAttribute("user",user);
  47.                 session.setMaxInactiveInterval(1200);
  48.                 out.println("hello "+user.toString()+"<br />");
  49.             }
  50.             else // bad login
  51.             {
  52.               out.println("invalid login<br />");  
  53.             }
  54.          
  55.             prep.close();                      
  56.            
  57.            con.close();
  58.            
  59.           }
  60.           catch(Exception ex)
  61.           {
  62.            out.println("Sorry, system is not currently available<br/>");
  63.            out.println(ex.toString());
  64.           }
  65.        
  66.         %>
  67.       </div>
  68.     </body>
  69. </html>
Add Comment
Please, Sign In to add comment