Commit 972021c6 authored by Dio Harvandy's avatar Dio Harvandy

Perbaikan Tampilan-tampilan

parent 1f5a8742
...@@ -34,7 +34,7 @@ public class Login extends HttpServlet { ...@@ -34,7 +34,7 @@ public class Login extends HttpServlet {
*/ */
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
HttpSession session = request.getSession(false); HttpSession session = request.getSession(false);
if (request.getParameter("logout") != null) { if (request.getParameter("logout") != null || session != null) {
session.invalidate(); session.invalidate();
response.sendRedirect(request.getContextPath()); response.sendRedirect(request.getContextPath());
} }
...@@ -51,19 +51,20 @@ public class Login extends HttpServlet { ...@@ -51,19 +51,20 @@ public class Login extends HttpServlet {
Statement stmt = (Statement) con.createStatement(); Statement stmt = (Statement) con.createStatement();
ResultSet rs = ResultSet rs =
stmt.executeQuery("select * from tbl_user where email = '"+ stmt.executeQuery("select * from tbl_user where email = '"+
request.getParameter("email").toString()+"' and password = "+request.getParameter("password")); request.getParameter("email").toString()+"' and password = '"+request.getParameter("password")+"'");
rs.next();
response.setContentType("text/html;charset=UTF-8"); if(rs.next()) {
PrintWriter out = response.getWriter(); // String emailRes = request.getParameter("email").toString();
String emailRes = request.getParameter("email").toString(); // String passwordRes = request.getParameter("password").toString();
String passwordRes = request.getParameter("password").toString(); // if(passwordRes.equals(rs.getString("password")) && emailRes.equals(rs.getString("email"))) {
if(passwordRes.equals(rs.getString("password")) && emailRes.equals(rs.getString("email"))) { HttpSession session = request.getSession(true);
HttpSession session = request.getSession(true); session.putValue("nama", rs.getString("nama"));
session.putValue("nama", rs.getString("nama")); session.putValue("email", rs.getString("email"));
session.putValue("email", rs.getString("email")); response.sendRedirect(request.getContextPath()+"/datamahasiswa");
response.sendRedirect(request.getContextPath()+"/datamahasiswa");
} }
else { else {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
out.println("<hmtl>"); out.println("<hmtl>");
out.println("<head>"); out.println("<head>");
out.println("<title>Login Gagal</title>"); out.println("<title>Login Gagal</title>");
...@@ -71,7 +72,7 @@ public class Login extends HttpServlet { ...@@ -71,7 +72,7 @@ public class Login extends HttpServlet {
out.println("<body>"); out.println("<body>");
out.println("<h1 style='text-align: center;'>Login Gagal</h1>"); out.println("<h1 style='text-align: center;'>Login Gagal</h1>");
out.println("<h3 style='text-align: center;'>Email atau Password Anda Salah</h3>"); out.println("<h3 style='text-align: center;'>Email atau Password Anda Salah</h3>");
out.println("<h3 style='text-align: center;'><a href='index.jsp'>Kembali</a></h3>"); out.println("<h3 style='text-align: center;'><a href='Index.jsp'>Kembali</a></h3>");
out.println("</body>"); out.println("</body>");
out.println("</hmtl>"); out.println("</hmtl>");
} }
......
...@@ -10,12 +10,11 @@ ...@@ -10,12 +10,11 @@
<title>Edit Data Mahasiswa</title> <title>Edit Data Mahasiswa</title>
</head> </head>
<body> <body>
<ul class="nav justify-content-end navbar-light bg-light"> <ul class="navbar navbar-expand-lg justify-content-end navbar-light bg-light">
<li class="nav-item"> <div class="nav-item ">
<a class="nav-link" onclick="return confirm('Logout?');" href="login?logout=1"><%= session.getAttribute("email") %> <i class="fa fa-sign-out" aria-hidden="true"></i></a> <a class="nav-link" onclick="return confirm('Logout?');" href="login?logout=1"><%= session.getAttribute("email") %> <i class="fa fa-sign-out" aria-hidden="true"></i></a>
</li> </div>
</ul> </ul>
<p class="text-center"></p>
<div class="container"> <div class="container">
<div class="card m-auto"> <div class="card m-auto">
<div class="card-header"> <div class="card-header">
......
...@@ -10,12 +10,11 @@ ...@@ -10,12 +10,11 @@
<title>Tambah Data Mahasiswa</title> <title>Tambah Data Mahasiswa</title>
</head> </head>
<body> <body>
<ul class="nav justify-content-end navbar-light bg-light"> <ul class="navbar navbar-expand-lg justify-content-end navbar-light bg-light">
<li class="nav-item"> <div class="nav-item ">
<a class="nav-link" onclick="return confirm('Logout?');" href="login?logout=1"><%= session.getAttribute("email") %> <i class="fa fa-sign-out" aria-hidden="true"></i></a> <a class="nav-link" onclick="return confirm('Logout?');" href="login?logout=1"><%= session.getAttribute("email") %> <i class="fa fa-sign-out" aria-hidden="true"></i></a>
</li> </div>
</ul> </ul>
<p class="text-center"></p>
<div class="container"> <div class="container">
<div class="card m-auto"> <div class="card m-auto">
<div class="card-header"> <div class="card-header">
......
...@@ -15,19 +15,20 @@ ...@@ -15,19 +15,20 @@
<style type="text/css"> <style type="text/css">
td{ td{
border: 1px solid; border: 1px solid;
text-align: center;
} }
</style> </style>
<title>Data Mahasiswa</title> <title>Data Mahasiswa</title>
</head> </head>
<body> <body>
<ul class="nav justify-content-end navbar-light bg-light">
<li class="nav-item"> <ul class="navbar navbar-expand-lg justify-content-end navbar-light bg-light">
<a href="datamahasiswa" class="navbar-brand text-muted">Data Mahasiswa</a>|
<div class="nav-item ">
<a class="nav-link" onclick="return confirm('Logout?');" href="login?logout=1"><%= session.getAttribute("email") %> <i class="fa fa-sign-out" aria-hidden="true"></i></a> <a class="nav-link" onclick="return confirm('Logout?');" href="login?logout=1"><%= session.getAttribute("email") %> <i class="fa fa-sign-out" aria-hidden="true"></i></a>
</li> </div>
</ul> </ul>
<p class="text-center">${pesan}</p> <p class="text-center">${pesan}</p>
<a href="datamahasiswa" class="nav-link"><h4 class="text-muted text-center">Data Mahasiswa</h4></a>
<div class="table-responsive-xxl"> <div class="table-responsive-xxl">
<table class="table table-sm table-striped table-hover" style="width: 95%; margin: auto;"> <table class="table table-sm table-striped table-hover" style="width: 95%; margin: auto;">
<thead> <thead>
...@@ -46,7 +47,7 @@ ...@@ -46,7 +47,7 @@
<th style="text-align: center;" scope="col" width="5px">Nama Panggilan</th> <th style="text-align: center;" scope="col" width="5px">Nama Panggilan</th>
<th style="text-align: center; width: 8%;" scope="col">Tempat Lahir</th> <th style="text-align: center; width: 8%;" scope="col">Tempat Lahir</th>
<th style="text-align: center; width: 8%;" scope="col">Tanggal Lahir</th> <th style="text-align: center; width: 8%;" scope="col">Tanggal Lahir</th>
<th style="text-align: center;" scope="col" width="5px">Jenis Kelamin</th> <th style="text-align: center;" scope="col">Jenis Kelamin</th>
<th style="text-align: center; width: 9%;" scope="col">Hobi</th> <th style="text-align: center; width: 9%;" scope="col">Hobi</th>
<th style="text-align: center; width: 10%;" scope="col">Email</th> <th style="text-align: center; width: 10%;" scope="col">Email</th>
<th style="text-align: center;" scope="col" width="5px">Anak Ke</th> <th style="text-align: center;" scope="col" width="5px">Anak Ke</th>
...@@ -58,9 +59,10 @@ ...@@ -58,9 +59,10 @@
<tbody> <tbody>
<% List<Mahasiswa> mhsList = (ArrayList<Mahasiswa>)request.getAttribute("mhsList"); <% List<Mahasiswa> mhsList = (ArrayList<Mahasiswa>)request.getAttribute("mhsList");
SimpleDateFormat sdf = new SimpleDateFormat("dd MMMM yyyy",new Locale("id", "ID")); SimpleDateFormat sdf = new SimpleDateFormat("dd MMMM yyyy",new Locale("id", "ID"));
int no = 1;
for (Mahasiswa mhs : mhsList){ String[] hobi = mhs.getHobi().split(";");%> for (Mahasiswa mhs : mhsList){ String[] hobi = mhs.getHobi().split(";");%>
<tr> <tr>
<td scope="row"><%= mhs.getId() %></td> <td scope="row"><%= no %></td>
<td><%= mhs.getNama() %></td> <td><%= mhs.getNama() %></td>
<td><%= mhs.getNamaPanggilan() %></td> <td><%= mhs.getNamaPanggilan() %></td>
<td><%= mhs.getTempatLahir() %></td> <td><%= mhs.getTempatLahir() %></td>
...@@ -74,7 +76,7 @@ ...@@ -74,7 +76,7 @@
<td style="text-align: center;"><a href="editdatamahasiswa?id=<%= mhs.getId() %>" class="btn btn-sm btn-warning"><i class="fa fa-pencil" aria-hidden="true"></i></a> <td style="text-align: center;"><a href="editdatamahasiswa?id=<%= mhs.getId() %>" class="btn btn-sm btn-warning"><i class="fa fa-pencil" aria-hidden="true"></i></a>
<a href="deletedatamahasiswa?id=<%= mhs.getId() %>" class="btn btn-sm btn-danger" onclick="return confirm('Delete This Item?');"><i class="fa fa-trash" aria-hidden="true"></i></a></td> <a href="deletedatamahasiswa?id=<%= mhs.getId() %>" class="btn btn-sm btn-danger" onclick="return confirm('Delete This Item?');"><i class="fa fa-trash" aria-hidden="true"></i></a></td>
</tr> </tr>
<%}%> <%no++;}%>
</tbody> </tbody>
</table> </table>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment