Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
belajarJavaServlet_Fabian
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Fabian Dewantara Santonie
belajarJavaServlet_Fabian
Commits
d3c7eddf
Commit
d3c7eddf
authored
Mar 24, 2022
by
Fabian Dewantara Santonie
🕊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Menambahkan menu Edit
parent
72c84e4f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
101 additions
and
0 deletions
+101
-0
edit.java
src/main/java/org/testing/bank/edit.java
+71
-0
edit.jsp
src/main/webapp/edit.jsp
+27
-0
index.jsp
src/main/webapp/index.jsp
+2
-0
view.jsp
src/main/webapp/view.jsp
+1
-0
No files found.
src/main/java/org/testing/bank/edit.java
0 → 100644
View file @
d3c7eddf
package
org
.
testing
.
bank
;
import
java.io.IOException
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
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
(
"/editData"
)
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
{
// TODO Auto-generated method stub
try
{
Connection
con
=
DatabaseConnection
.
initializeDatabase
();
Statement
stmt
=
(
Statement
)
con
.
createStatement
();
ResultSet
rs
=
stmt
.
executeQuery
(
"select * from bank where id = "
+
Integer
.
valueOf
(
request
.
getParameter
(
"id"
)));
rs
.
next
();
request
.
setAttribute
(
"id"
,
rs
.
getInt
(
"id"
));
request
.
setAttribute
(
"kode"
,
rs
.
getString
(
"kode"
));
request
.
setAttribute
(
"nama"
,
rs
.
getString
(
"nama"
));
request
.
getRequestDispatcher
(
"edit.jsp"
).
forward
(
request
,
response
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
protected
void
doPost
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
try
{
Connection
con
=
DatabaseConnection
.
initializeDatabase
();
PreparedStatement
st
=
con
.
prepareStatement
(
"update bank set kode = ?, nama = ? where id = ?"
);
st
.
setString
(
1
,
request
.
getParameter
(
"kode"
));
st
.
setString
(
2
,
request
.
getParameter
(
"nama"
));
st
.
setString
(
3
,
request
.
getParameter
(
"id"
));
st
.
executeUpdate
();
st
.
close
();
con
.
close
();
response
.
sendRedirect
(
request
.
getContextPath
()+
"/editData"
);
}
catch
(
ClassNotFoundException
|
SQLException
e
)
{
e
.
printStackTrace
();
}
}
}
src/main/webapp/edit.jsp
0 → 100644
View file @
d3c7eddf
<%@ page
language=
"java"
contentType=
"text/html; charset=ISO-8859-1"
pageEncoding=
"ISO-8859-1"
%>
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"ISO-8859-1"
>
<title>
Insert title here
</title>
</head>
<body>
<div
align=
"center"
>
<table
class=
"table-sm"
border=
"2"
>
<tr>
<th>
ID
</th>
<th>
Kode
</th>
<th>
Nama Bank
</th>
</tr>
<tr>
<th>
${id}
</th>
<th>
${kode}
</th>
<th>
${nama}
</th>
</tr>
</div>
</form>
</body>
</html>
\ No newline at end of file
src/main/webapp/index.jsp
View file @
d3c7eddf
...
...
@@ -7,6 +7,7 @@
<meta
charset=
"ISO-8859-1"
>
<title>
Insert title here
</title>
</head>
<div
align=
"center"
>
<body>
<a
href=
"Latihan1.jsp"
><button
class=
"btn btn-dark"
>
Latihan 1
</button></a>
<a
href=
"Latihan2.jsp"
><button
class=
"btn btn-dark"
>
Latihan 2
</button></a>
...
...
@@ -14,4 +15,5 @@
<a
href=
"Latihan4.jsp"
><button
class=
"btn btn-dark"
>
Latihan 4
</button></a>
<a
href=
"/belajarJavaServlet_Fabian/DatabaseConnect"
><button
class=
"btn btn-dark"
>
Latihan 5
</button></a>
</body>
</div>
</html>
\ No newline at end of file
src/main/webapp/view.jsp
View file @
d3c7eddf
...
...
@@ -26,6 +26,7 @@
<td><%=
bank
.
getId
()
%></td>
<td><%=
bank
.
getKode
()
%></td>
<td><%=
bank
.
getNama
()
%></td>
<td><a
href=
"editData?id=
<%=
bank
.
getId
()
%>
"
><button
class=
"btn btn-dark"
>
Edit
</button></a></td>
</tr>
<%
}
%>
</table>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment