Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
LatihanJavaServlet_dioharvandy
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
Dio Harvandy
LatihanJavaServlet_dioharvandy
Commits
c135107a
Commit
c135107a
authored
Mar 21, 2022
by
Dio Harvandy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Latihan 3
Input username dan password
parent
b02fd605
Pipeline
#6522
canceled with stages
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
112 additions
and
0 deletions
+112
-0
Latihan3.java
src/main/java/com/latihan/web/Latihan3.java
+83
-0
Latihan3.jsp
src/main/webapp/Latihan3.jsp
+29
-0
No files found.
src/main/java/com/latihan/web/Latihan3.java
0 → 100644
View file @
c135107a
package
com
.
latihan
.
web
;
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
;
/**
* Servlet implementation class Latihan3
*/
@WebServlet
(
"/Latihan3"
)
public
class
Latihan3
extends
HttpServlet
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* @see HttpServlet#HttpServlet()
*/
public
Latihan3
()
{
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
{
response
.
setContentType
(
"text/html;charset=UTF-8"
);
String
username
=
"dio"
;
String
password
=
"123"
;
PrintWriter
out
=
response
.
getWriter
();
String
usernameRes
=
request
.
getParameter
(
"username"
).
toString
();
String
passwordRes
=
request
.
getParameter
(
"password"
).
toString
();
if
(
username
.
equals
(
usernameRes
)
&&
password
.
equals
(
passwordRes
))
{
out
.
println
(
"<hmtl>"
);
out
.
println
(
"<head>"
);
out
.
println
(
"<title>Latihan 3 Sukses</title>"
);
out
.
println
(
"</head>"
);
out
.
println
(
"<body>"
);
out
.
println
(
"<h1 style='text-align: center;'>Login Sukses</h1>"
);
out
.
println
(
"<h3 style='text-align: center;'>Selamat Datang "
+
username
.
toUpperCase
()+
"</h3>"
);
out
.
println
(
"</body>"
);
out
.
println
(
"</hmtl>"
);
}
else
if
(!
username
.
equals
(
usernameRes
))
{
out
.
println
(
"<hmtl>"
);
out
.
println
(
"<head>"
);
out
.
println
(
"<title>Latihan 3 Gagal</title>"
);
out
.
println
(
"</head>"
);
out
.
println
(
"<body>"
);
out
.
println
(
"<h1 style='text-align: center;'>Login Gagal</h1>"
);
out
.
println
(
"<h3 style='text-align: center;'>Username Anda Salah</h3>"
);
out
.
println
(
"<h3 style='text-align: center;'><a href='Latihan3.jsp'>Kembali</a></h3>"
);
out
.
println
(
"</body>"
);
out
.
println
(
"</hmtl>"
);
}
else
if
(!
password
.
equals
(
passwordRes
))
{
out
.
println
(
"<hmtl>"
);
out
.
println
(
"<head>"
);
out
.
println
(
"<title>Latihan 3 Gagal</title>"
);
out
.
println
(
"</head>"
);
out
.
println
(
"<body>"
);
out
.
println
(
"<h1 style='text-align: center;'>Login Gagal</h1>"
);
out
.
println
(
"<h3 style='text-align: center;'>Password Anda Salah</h3>"
);
out
.
println
(
"<h3 style='text-align: center;'><a href='Latihan3.jsp'>Kembali</a></h3>"
);
out
.
println
(
"</body>"
);
out
.
println
(
"</hmtl>"
);
}
System
.
out
.
println
(
"Service"
);
}
}
src/main/webapp/Latihan3.jsp
0 → 100644
View file @
c135107a
<%@ 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>
<form
action=
"Latihan3"
method=
"POST"
>
<table
style=
"border: 1px solid; margin: auto;"
>
<tr>
<th
colspan=
"2"
style=
"padding: 10px"
>
Login
</th>
</tr>
<tr>
<td><label>
Username
</label></td>
<td>
:
<input
name =
"username"
type =
"text"
></td>
</tr>
<tr>
<td><label>
Password
</label></td>
<td>
:
<input
name =
"password"
type =
"password"
></td>
</tr>
<tr>
<th
colspan=
"2"
style=
"padding: 10px"
><button
type =
"submit"
>
Submit
</button></th>
</tr>
</table>
</form>
</body>
</html>
\ No newline at end of file
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