0% found this document useful (0 votes)
44 views3 pages

Hibernate 8

Uploaded by

Aung Nway Oo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views3 pages

Hibernate 8

Uploaded by

Aung Nway Oo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

JSP+MySql+Hibernate

menu.jsp

<ul class="navbar-nav ml-auto">


<li class="nav-item ">
<a class="nav-link" href="login.jsp">Logout</a>
</li>
</ul>

login.jsp

<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>


<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Spring MVC</title>
<link rel="stylesheet"
href="<c:url value="/resources/css/bootstrap.min.css"/>" />

</head>
<body>
<div class="container col-sm-5 row-sm-500" style="background: #cdd; width:500">
<form role="form" action="login" method="post">
<div class="form-group">
<label>Email address</label>
<input type="email" class="form-control" placeholder="Email" name="em">

1| Hibernate
</div>
<div class="form-group">
<label >Password</label>
<input type="password" class="form-control" placeholder="Password" name="pw">
</div>
<div class="form-group">
<button type="submit" class="btn btn-default">Login</button>
</div>

</form>
</div>

</body>
</html>

Login.java

package controller;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet(urlPatterns = {"/login"})
public class Login extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
String em = request.getParameter("em");
String psw = request.getParameter("pw");

if (em.equals("[email protected]") && psw.equals("123")) {


response.sendRedirect("home.jsp");

} else {

response.sendRedirect("login.jsp");
}

}
}
protected void doGet (HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
protected void doPost (HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}

2| Hibernate
}

3| Hibernate

You might also like