Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%--
- Document : Login
- Created on : Mar 27, 2012, 5:48:49 PM
- Author : mpenderg
- --%>
- <%@page contentType="text/html" pageEncoding="UTF-8"%>
- <%@page import="java.sql.*"%>
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>Login</title>
- <LINK rel="stylesheet" type = "text/css" href="College.css" />
- <LINK rel="stylesheet" type = "text/css" href="SimpleMenu.css" />
- </head>
- <body>
- <script src ="Common.js"></Script>
- <div class="center">
- <script src ="menu.js"></Script>
- <br />
- <br />
- <%
- try{
- Connection con = null;
- Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); // load the driver
- con = DriverManager.getConnection("jdbc:sqlserver://rubble.student.ad.fgcu.edu:1433;databaseName=sp12ism3232e;user=s12ISM3232E;password=s12ISM3232E;");
- String usercabin = request.getParameter("userlog");
- String password = request.getParameter("password");
- PreparedStatement prep = con.prepareStatement("Select * from UserT where username = ? and password = ?");
- prep.setString(1,usercabin);
- prep.setString(2,password);
- ResultSet rs = prep.executeQuery();
- if(rs.next())
- {
- String login = rs.getString(1);
- String pass = rs.getString(2);
- dbutility.UserLogin user = new dbutility.UserLogin(login, pass);
- session.setAttribute("user",user);
- session.setMaxInactiveInterval(1200);
- out.println("hello "+user.toString()+"<br />");
- }
- else // bad login
- {
- out.println("invalid login<br />");
- }
- prep.close();
- con.close();
- }
- catch(Exception ex)
- {
- out.println("Sorry, system is not currently available<br/>");
- out.println(ex.toString());
- }
- %>
- </div>
- </body>
- </html>
Add Comment
Please, Sign In to add comment