Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@ page contentType="text/html" pageEncoding="UTF-8"%>
- <%@ page errorPage="error.jsp" %>
- <%@ page language="java"%>
- <%@ page import="java.sql.*" %>
- <%!
- boolean validateUser(String name, String password) {
- try {
- String connectionURL = "jdbc:mysql://mysql.stud.ntnu.no:3306/kristwin_ov1";
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- Connection connection = DriverManager.getConnection(connectionURL, "kristwin_progsik", "DhEL1337");
- // check weather connection is established or not by isClosed() method
- if(!connection.isClosed()) {
- return true;
- }
- }
- catch(Exception ex) {
- //Log this?
- } finally {
- connection.close();
- }
- return false;
- }
- %>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <link rel="stylesheet" type="text/css" href="lutstyle.css">
- <title>LUT Login Pages</title>
- </head>
- <body>
- <%
- if(validateUser(${param.username}, ${param.password})) {
- out.println("Success!");
- }
- else {
- out.println("Failed!");
- }
- %>
- </body>
- </html>
Add Comment
Please, Sign In to add comment