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
8dcd8e14
Commit
8dcd8e14
authored
Mar 22, 2022
by
Fabian Dewantara Santonie
🕊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Menambahkan request Session pada Latihan 3
parent
fe299066
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
2 deletions
+51
-2
Latihan3.java
src/main/java/org/testing/inputName/Latihan3.java
+5
-2
Second.java
src/main/java/org/testing/inputName/Second.java
+46
-0
No files found.
src/main/java/org/testing/inputName/Latihan3.java
View file @
8dcd8e14
...
...
@@ -9,6 +9,7 @@ import javax.servlet.annotation.WebServlet;
import
javax.servlet.http.HttpServlet
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpSession
;
/**
* Servlet implementation class Latihan3
...
...
@@ -48,8 +49,10 @@ public class Latihan3 extends HttpServlet {
out
.
println
(
"</head>"
);
out
.
println
(
"<body>"
);
if
(
username
!=
null
&&
username
.
equalsIgnoreCase
(
"fabian"
))
{
if
(
password
!=
null
&&
password
.
equalsIgnoreCase
(
"fabian"
))
{
out
.
println
(
"Welcome "
+
username
);
if
(
password
!=
null
&&
password
.
equals
(
"fabian"
))
{
HttpSession
session
=
request
.
getSession
(
true
);
session
.
putValue
(
"username"
,
username
);
response
.
sendRedirect
(
request
.
getContextPath
()+
"/Second"
);
}
else
{
out
.
println
(
"Password Salah!"
);
...
...
src/main/java/org/testing/inputName/Second.java
0 → 100644
View file @
8dcd8e14
package
org
.
testing
.
inputName
;
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
;
import
javax.servlet.http.HttpSession
;
/**
* Servlet implementation class Second
*/
@WebServlet
(
"/Second"
)
public
class
Second
extends
HttpServlet
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* @see HttpServlet#HttpServlet()
*/
public
Second
()
{
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
PrintWriter
out
=
response
.
getWriter
();
HttpSession
session
=
request
.
getSession
(
true
);
String
username
=
(
String
)
session
.
getValue
(
"username"
);
PrintWriter
writer
=
response
.
getWriter
();
String
htmlRespone
=
"<html>"
;
htmlRespone
+=
"<h2>Selamat Datang "
+
username
+
"<br/>"
;
htmlRespone
+=
"</html>"
;
writer
.
println
(
htmlRespone
);
}
}
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