Commit cf395d56 authored by Dwinowo Muhammad's avatar Dwinowo Muhammad

CRUD Latihan 5 + Perapihan folder file

parent 2c26a560
package com.belajarServlet.web; package com.latihan1;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
......
package com.belajarServlet.web; package com.latihan2;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
......
package com.belajarServlet.web; package com.latihan3;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
...@@ -60,15 +60,15 @@ public class Latihan3 extends HttpServlet { ...@@ -60,15 +60,15 @@ public class Latihan3 extends HttpServlet {
} else if (!password.equals(passwordAgus) && !userName.equals(userAgus)) { } else if (!password.equals(passwordAgus) && !userName.equals(userAgus)) {
out.println("<h1> Login Gagal </h1>"); out.println("<h1> Login Gagal </h1>");
out.println("<p> Username dan password anda salah!!! </p>"); out.println("<p> Username dan password anda salah!!! </p>");
out.println("<a href=\"Latihan3.jsp\"><button>Kembali</button></a>"); out.println("<a href=\"/latihanJavaServlet_Dwinowo_Muhammad/Latihan3/Latihan3.jsp\"><button>Kembali</button></a>");
} else if (!userName.equals(userAgus)) { } else if (!userName.equals(userAgus)) {
out.println("<h1> Login Gagal </h1>"); out.println("<h1> Login Gagal </h1>");
out.println("<p> Username anda salah!!! </p>"); out.println("<p> Username anda salah!!! </p>");
out.println("<a href=\"Latihan3.jsp\"><button>Kembali</button></a>"); out.println("<a href=\"/latihanJavaServlet_Dwinowo_Muhammad/Latihan3/Latihan3.jsp\"><button>Kembali</button></a>");
} else if (!password.equals(passwordAgus)) { } else if (!password.equals(passwordAgus)) {
out.println("<h1> Login Gagal </h1>"); out.println("<h1> Login Gagal </h1>");
out.println("<p> Password anda salah!!! </p>"); out.println("<p> Password anda salah!!! </p>");
out.println("<a href=\"Latihan3.jsp\"><button>Kembali</button></a>"); out.println("<a href=\"/latihanJavaServlet_Dwinowo_Muhammad/Latihan3/Latihan3.jsp\"><button>Kembali</button></a>");
} }
out.println("</body>"); out.println("</body>");
out.println("</html>"); out.println("</html>");
......
...@@ -96,12 +96,12 @@ public class Latihan4 extends HttpServlet { ...@@ -96,12 +96,12 @@ public class Latihan4 extends HttpServlet {
request.setAttribute("anakKe", anakKe); request.setAttribute("anakKe", anakKe);
request.setAttribute("pendidikanTerakhir", pendidikanTerkahir); request.setAttribute("pendidikanTerakhir", pendidikanTerkahir);
request.setAttribute("alamat", alamat); request.setAttribute("alamat", alamat);
request.getRequestDispatcher("detailDaftarKaryawan.jsp").forward(request, response); request.getRequestDispatcher("Latihan4/detailDaftarKaryawan.jsp").forward(request, response);
HttpSession session = request.getSession(false); HttpSession session = request.getSession(false);
String username = (String) session.getAttribute("username"); String username = (String) session.getAttribute("username");
session.setAttribute("username", username); session.setAttribute("username", username);
request.getRequestDispatcher("detailDaftarKaryawan.jsp").forward(request, response); request.getRequestDispatcher("Latihan4/detailDaftarKaryawan.jsp").forward(request, response);
doGet(request, response); doGet(request, response);
} }
......
...@@ -54,22 +54,23 @@ public class login extends HttpServlet { ...@@ -54,22 +54,23 @@ public class login extends HttpServlet {
session.setAttribute("username", userName); session.setAttribute("username", userName);
request.getRequestDispatcher("Latihan4.jsp").forward(request, response); request.getRequestDispatcher("Latihan4/Latihan4.jsp").forward(request, response);
request.getRequestDispatcher("detailDaftarKaryawan.jsp").forward(request, response); request.getRequestDispatcher("Latihan4/detailDaftarKaryawan.jsp").forward(request, response);
response.sendRedirect(request.getContextPath() + "/Latihan4.jsp"); // response.sendRedirect(request.getContextPath() + "/Latihan4/Latihan4.jsp");
response.sendRedirect("/latihanJavaServlet_Dwinowo_Muhammad/Latihan4/Latihan4.jsp");
} else if (!password.equals(passwordAgus) && !userName.equals(userAgus)) { } else if (!password.equals(passwordAgus) && !userName.equals(userAgus)) {
out.println("<h1> Login Gagal </h1>"); out.println("<h1> Login Gagal </h1>");
out.println("<p> Username dan password anda salah!!! </p>"); out.println("<p> Username dan password anda salah!!! </p>");
out.println("<a href=\"login.jsp\"><button>Kembali</button></a>"); out.println("<a href=\"/latihanJavaServlet_Dwinowo_Muhammad/Latihan4/login.jsp\"><button>Kembali</button></a>");
} else if (!userName.equals(userAgus)) { } else if (!userName.equals(userAgus)) {
out.println("<h1> Login Gagal </h1>"); out.println("<h1> Login Gagal </h1>");
out.println("<p> Username anda salah!!! </p>"); out.println("<p> Username anda salah!!! </p>");
out.println("<a href=\"login.jsp\"><button>Kembali</button></a>"); out.println("<a href=\"/latihanJavaServlet_Dwinowo_Muhammad/Latihan4/login.jsp\"><button>Kembali</button></a>");
} else if (!password.equals(passwordAgus)) { } else if (!password.equals(passwordAgus)) {
out.println("<h1> Login Gagal </h1>"); out.println("<h1> Login Gagal </h1>");
out.println("<p> Password anda salah!!! </p>"); out.println("<p> Password anda salah!!! </p>");
out.println("<a href=\"login.jsp\"><button>Kembali</button></a>"); out.println("<a href=\"/latihanJavaServlet_Dwinowo_Muhammad/Latihan4/login.jsp\"><button>Kembali</button></a>");
} }
doGet(request, response); doGet(request, response);
......
package com.mysql; package com.latihan5;
public class Bank { public class Bank {
protected int id; protected int id;
......
package com.mysql; package com.latihan5;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
......
package com.belajarServlet.web; package com.latihan5;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.sql.Connection;
import java.sql.PreparedStatement;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet; import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/** /**
* Servlet implementation class DashboardProfile * Servlet implementation class Delete
*/ */
@WebServlet("/DashboardProfile") @WebServlet("/Delete")
public class DashboardProfile extends HttpServlet { public class Delete extends HttpServlet {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* @see HttpServlet#HttpServlet() * @see HttpServlet#HttpServlet()
*/ */
public DashboardProfile() { public Delete() {
super(); super();
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
...@@ -29,31 +29,40 @@ public class DashboardProfile extends HttpServlet { ...@@ -29,31 +29,40 @@ public class DashboardProfile extends HttpServlet {
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/ */
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
PrintWriter out = response.getWriter(); response.getWriter().append("Served at: ").append(request.getContextPath());
HttpSession session = request.getSession(true);
String username = (String) session.getValue("username");
// get response writer
PrintWriter writer = response.getWriter();
// build html code
String htmlResponse = "<html>";
htmlResponse += "<h2> Selamat Datang " + username + "<br/>";
//return response
writer.println(htmlResponse);
// response.getWriter().append("Served at: ").append(request.getContextPath());
} }
/** /**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/ */
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
try {
Connection con = DatabaseConnection.initializeDatabase();
// EDIT dibawah ==================================================
String sqlDelete = "DELETE FROM bank WHERE id = ?";
int idBaru = Integer.parseInt(request.getParameter("idBaru"));
PreparedStatement statementDelete = con.prepareStatement(sqlDelete);
statementDelete.setInt(1, idBaru);
statementDelete.executeUpdate();
statementDelete.close();
con.close();
response.sendRedirect("/latihanJavaServlet_Dwinowo_Muhammad/servletSql");
} catch (Exception e) {
// TODO: handle exception
}
doGet(request, response); doGet(request, response);
} }
......
package com.latihan5;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class Edit
*/
@WebServlet("/Edit")
public class Edit extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public Edit() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
Connection con = DatabaseConnection.initializeDatabase();
// EDIT dibawah ==================================================
String sqlEdit = "UPDATE bank SET nama = ?, kode = ? WHERE id = ?";
int idBaru = Integer.parseInt(request.getParameter("idBaru"));
PreparedStatement statementEdit = con.prepareStatement(sqlEdit);
statementEdit.setString(1, request.getParameter("namaEdit"));
statementEdit.setString(2, request.getParameter("kodeEdit"));
statementEdit.setInt(3, idBaru);
statementEdit.executeUpdate();
statementEdit.close();
con.close();
response.sendRedirect("/latihanJavaServlet_Dwinowo_Muhammad/servletSql");
} catch (Exception e) {
// TODO: handle exception
}
doGet(request, response);
}
}
package com.latihan5;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class ViewSelectedDelete
*/
@WebServlet("/ViewSelectedDelete")
public class ViewSelectedDelete extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public ViewSelectedDelete() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.getWriter().append("Served at: ").append(request.getContextPath());
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
Connection con = DatabaseConnection.initializeDatabase();
Bank bank = new Bank();
String sql = "SELECT * FROM bank WHERE id = ?";
PreparedStatement statement = con.prepareStatement(sql);
statement.setInt(1, Integer.valueOf(request.getParameter("bankObjek")));
ResultSet resultSet = statement.executeQuery();
if (resultSet.next()) {
int id = resultSet.getInt("id");
String kode = resultSet.getString("kode");
String nama = resultSet.getString("nama");
bank.setId(id);
bank.setKode(kode);
bank.setNama(nama);
}
request.setAttribute("bankSatuan", bank);
resultSet.close();
statement.close();
request.getRequestDispatcher("Latihan5/delete.jsp").forward(request, response);
response.sendRedirect("/latihanJavaServlet_Dwinowo_Muhammad/Latihan5/delete.jsp");
} catch (Exception e) {
// TODO: handle exception
}
doGet(request, response);
}
}
package com.mysql; package com.latihan5;
import java.io.IOException; import java.io.IOException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import com.mysql.Bank;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet; import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/** /**
* Servlet implementation class Edit * Servlet implementation class ViewDiEdit
*/ */
@WebServlet("/Edit") @WebServlet("/ViewSelectedEdit")
public class Edit extends HttpServlet { public class ViewSelectedEdit extends HttpServlet {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* @see HttpServlet#HttpServlet() * @see HttpServlet#HttpServlet()
*/ */
public Edit() { public ViewSelectedEdit() {
super(); super();
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
...@@ -39,14 +33,17 @@ public class Edit extends HttpServlet { ...@@ -39,14 +33,17 @@ public class Edit extends HttpServlet {
response.getWriter().append("Served at: ").append(request.getContextPath());
} }
/** /**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/ */
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
try {
Connection con = DatabaseConnection.initializeDatabase(); Connection con = DatabaseConnection.initializeDatabase();
Bank bank = new Bank(); Bank bank = new Bank();
...@@ -72,17 +69,13 @@ public class Edit extends HttpServlet { ...@@ -72,17 +69,13 @@ public class Edit extends HttpServlet {
resultSet.close(); resultSet.close();
statement.close(); statement.close();
request.getRequestDispatcher("Latihan5/edit.jsp").forward(request, response);
response.sendRedirect("/latihanJavaServlet_Dwinowo_Muhammad/Latihan5/edit.jsp");
request.getRequestDispatcher("edit.jsp").forward(request, response);
response.sendRedirect("/latihanJavaServlet_Dwinowo_Muhammad/edit.jsp");
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception // TODO: handle exception
} }
doGet(request, response); doGet(request, response);
} }
......
package com.mysql; package com.latihan5;
import java.io.IOException; import java.io.IOException;
import java.sql.Connection; import java.sql.Connection;
......
package com.mysql; package com.latihan5;
import java.io.IOException; import java.io.IOException;
import java.sql.Connection; import java.sql.Connection;
...@@ -59,8 +59,8 @@ public class servletSql extends HttpServlet { ...@@ -59,8 +59,8 @@ public class servletSql extends HttpServlet {
} }
request.setAttribute("bankList", bankList); request.setAttribute("bankList", bankList);
request.getRequestDispatcher("viewSql.jsp").forward(request, response); request.getRequestDispatcher("Latihan5/viewSql.jsp").forward(request, response);
request.getRequestDispatcher("edit.jsp").forward(request, response); // request.getRequestDispatcher("edit.jsp").forward(request, response);
// Create a sql query to insert data into demo table // Create a sql query to insert data into demo table
// demo table consists of two columns, so two '?' is used // demo table consists of two columns, so two '?' is used
......
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Selamat Datang</title>
</head>
<body>
</body>
</html>
\ No newline at end of file
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<body> <body>
<h2>Latihan 1</h2> <h2>Latihan 1</h2>
<form action="Latihan1"> <form action="/latihanJavaServlet_Dwinowo_Muhammad/Latihan1">
<label for="fname">First name:</label><br> <label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname"><br> <input type="text" id="fname" name="fname"><br>
<label for="lname">Last name:</label><br> <label for="lname">Last name:</label><br>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<title>Latihan 2</title> <title>Latihan 2</title>
</head> </head>
<body> <body>
<form action="Latihan2" method = "POST"> <form action="/latihanJavaServlet_Dwinowo_Muhammad/Latihan2" method = "POST">
<label for="fname">First name:</label><br> <label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname"><br> <input type="text" id="fname" name="fname"><br>
<label for="lname">Last name:</label><br> <label for="lname">Last name:</label><br>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<head> <head>
<meta charset="ISO-8859-1"> <meta charset="ISO-8859-1">
<title>Latihan3</title> <title>Latihan3</title>
<link rel="stylesheet" href="styles.css"> <link rel="stylesheet" href="/latihanJavaServlet_Dwinowo_Muhammad/css/login.css">
<link rel="shortcut icon" href="https://bit.ly/3qqTW6D" /> <link rel="shortcut icon" href="https://bit.ly/3qqTW6D" />
</head> </head>
<body> <body>
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<div id="wrapper"> <div id="wrapper">
<div class="main-content"> <div class="main-content">
<div class="header"> <div class="header">
<form action="Latihan3" method="post"> <form action="/latihanJavaServlet_Dwinowo_Muhammad/Latihan3" method="post">
<label for="fname">Username:</label><br> <input type="text" <label for="fname">Username:</label><br> <input type="text"
placeholder="username" class="input-1" id="username" placeholder="username" class="input-1" id="username"
name="username"><br> <label for="lname">Password:</label><br> name="username"><br> <label for="lname">Password:</label><br>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<title>Form Tambah Data Karyawan</title> <title>Form Tambah Data Karyawan</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="cssLatihan4.css"> <link rel="stylesheet" href="css/Latihan4/cssLatihan4.css">
<link href='https://fonts.googleapis.com/css?family=Nunito:400,300' <link href='https://fonts.googleapis.com/css?family=Nunito:400,300'
rel='stylesheet' type='text/css'> rel='stylesheet' type='text/css'>
......
...@@ -4,14 +4,16 @@ ...@@ -4,14 +4,16 @@
<html> <html>
<head> <head>
<meta charset="ISO-8859-1"> <meta charset="ISO-8859-1">
<link rel="stylesheet" href="/latihanJavaServlet_Dwinowo_Muhammad/css/login.css">
<title>Latihan 4</title> <title>Latihan 4</title>
<link rel="stylesheet" href="styles.css">
</head> </head>
<body> <body>
<div id="wrapper"> <div id="wrapper">
<div class="main-content"> <div class="main-content">
<div class="header"> <div class="header">
<form action="login" method="post"> <form action="/latihanJavaServlet_Dwinowo_Muhammad/login" method="post">
<label for="fname">Username:</label><br> <input type="text" <label for="fname">Username:</label><br> <input type="text"
placeholder="username" class="input-1" id="username" placeholder="username" class="input-1" id="username"
name="username"><br> <label for="lname">Password:</label><br> name="username"><br> <label for="lname">Password:</label><br>
......
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="com.latihan5.Bank"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<table border="2">
<tr>
<th>ID</th>
<th>Kode</th>
<th>Nama</th>
</tr>
<%
Bank bankBaru = (Bank) request.getAttribute("bankSatuan");
%>
<tr>
<td><%=bankBaru.getId()%></td>
<td><%=bankBaru.getKode()%></td>
<td><%=bankBaru.getNama()%></td>
</tr>
</table>
Apakah anda yakin untuk menghapus data di atas? <br/>
<form action="Delete" method="post">
<input type="hidden"
name="idBaru" value="<%=bankBaru.getId()%>">
<input
type="submit" value="Ya">
</form>
<form action="servletSql">
<input type="submit" value="Tidak"></form>
</body>
</html>
\ No newline at end of file
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%> pageEncoding="ISO-8859-1"%>
<%@ page import="java.util.ArrayList"%>
<%@ page import="java.util.List"%> <%@ page import="com.latihan5.Bank"%>
<%@ page import="com.mysql.Bank"%>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
...@@ -14,7 +13,7 @@ ...@@ -14,7 +13,7 @@
</head> </head>
<body> <body>
<table border="2"> <table border="2">
<tr> <tr>
<th>ID</th> <th>ID</th>
<th>Kode</th> <th>Kode</th>
...@@ -22,7 +21,7 @@ ...@@ -22,7 +21,7 @@
</tr> </tr>
<% <%
Bank bankBaru = (Bank) request.getAttribute("bankSatuan"); Bank bankBaru = (Bank) request.getAttribute("bankSatuan");
%> %>
<tr> <tr>
...@@ -30,9 +29,16 @@ ...@@ -30,9 +29,16 @@
<td><%=bankBaru.getKode()%></td> <td><%=bankBaru.getKode()%></td>
<td><%=bankBaru.getNama()%></td> <td><%=bankBaru.getNama()%></td>
</tr> </tr>
</table> </table>
<form action="Edit" method="post">
Nama : <input type="text" name="namaEdit"><br/>
Kode : <input type="text" name="kodeEdit"><br/>
<input type="hidden" name="idBaru" value="<%=bankBaru.getId()%>">
<input type="submit" value="Submit">
</form>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<title>Insert title here</title> <title>Insert title here</title>
</head> </head>
<body> <body>
<form name="insertForm" method="post" action="insertData"> <form name="insertForm" method="post" action="/latihanJavaServlet_Dwinowo_Muhammad/insertData">
Id : <input type="text" name="id"/><br/> Id : <input type="text" name="id"/><br/>
Kode : <input type="text" name="kode"/><br/> Kode : <input type="text" name="kode"/><br/>
Nama : <input type="text" name="nama"/><br/> Nama : <input type="text" name="nama"/><br/>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<%@ page import="java.util.ArrayList"%> <%@ page import="java.util.ArrayList"%>
<%@ page import="java.util.List"%> <%@ page import="java.util.List"%>
<%@ page import="com.mysql.Bank"%> <%@ page import="com.latihan5.Bank"%>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
...@@ -12,9 +12,12 @@ ...@@ -12,9 +12,12 @@
<title>Insert title here</title> <title>Insert title here</title>
</head> </head>
<body> <body>
<h2> <form action="Latihan5/insert.jsp" method="post">
<a href="insert.jsp">Tambah Data</a> <input type="submit" value="Tambah Data">
</h2>
</form>
<table border="2"> <table border="2">
<tr> <tr>
<th>ID</th> <th>ID</th>
...@@ -34,11 +37,23 @@ ...@@ -34,11 +37,23 @@
<td><%=bankList.get(i).getKode()%></td> <td><%=bankList.get(i).getKode()%></td>
<td><%=bankList.get(i).getNama()%></td> <td><%=bankList.get(i).getNama()%></td>
<td> <td>
<form action="Edit" method="post">
<input type="hidden" name="bankObjek" value="<%=bankList.get(i).getId()%>" /> <form action="ViewSelectedEdit" method="post">
<input type="submit" value="Edit">
<input type="hidden" name="bankObjek"
value="<%=bankList.get(i).getId()%>" /> <input type="submit"
value="Edit">
</form>
<form action="ViewSelectedDelete" method="post">
<input type="hidden" name="bankObjek"
value="<%=bankList.get(i).getId()%>" /> <input type="submit"
value="Hapus">
</form> </form>
......
...@@ -10,10 +10,10 @@ ...@@ -10,10 +10,10 @@
<h2>Latihan 1-5</h2> <h2>Latihan 1-5</h2>
<ul> <ul>
<li><a href="Latihan1.jsp">Latihan 1</a></li> <li><a href="/latihanJavaServlet_Dwinowo_Muhammad/Latihan1/Latihan1.jsp">Latihan 1</a></li>
<li><a href="Latihan2.jsp">Latihan 2</a></li> <li><a href="/latihanJavaServlet_Dwinowo_Muhammad/Latihan2/Latihan2.jsp">Latihan 2</a></li>
<li><a href="Latihan3.jsp">Latihan 3</a></li> <li><a href="/latihanJavaServlet_Dwinowo_Muhammad/Latihan3/Latihan3.jsp">Latihan 3</a></li>
<li><a href="login.jsp">Latihan 4</a></li> <li><a href="/latihanJavaServlet_Dwinowo_Muhammad/Latihan4/login.jsp">Latihan 4</a></li>
<li><a href="/latihanJavaServlet_Dwinowo_Muhammad/servletSql">Latihan 5</a></li> <li><a href="/latihanJavaServlet_Dwinowo_Muhammad/servletSql">Latihan 5</a></li>
</ul> </ul>
......
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