Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
servlets
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Oscar Enrique Gonzalez Escurra
servlets
Commits
808c1385
Commit
808c1385
authored
Jun 28, 2022
by
OscarGonzalez97
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
correcciones en ejemplos de RequestDispatcher
parent
d4b588da
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
6 deletions
+30
-6
src/main/java/com/roshka/bootcamp/RequestDispatcherServlet.java
+9
-5
src/main/java/com/roshka/bootcamp/RequestDispatcherServletSuccess.java
+1
-1
src/main/webapp/login-try.html
+19
-0
src/main/webapp/login.html
+1
-0
No files found.
src/main/java/com/roshka/bootcamp/RequestDispatcherServlet.java
View file @
808c1385
...
@@ -23,14 +23,18 @@ public class RequestDispatcherServlet extends HttpServlet {
...
@@ -23,14 +23,18 @@ public class RequestDispatcherServlet extends HttpServlet {
if
(
username
.
equals
(
"bootcamp"
)
&&
password
.
equals
(
"bootcamp"
))
{
if
(
username
.
equals
(
"bootcamp"
)
&&
password
.
equals
(
"bootcamp"
))
{
// forward
// forward
RequestDispatcher
dispatcher
=
request
.
getRequestDispatcher
(
"
RequestDispatcherServletS
uccess"
);
RequestDispatcher
dispatcher
=
request
.
getRequestDispatcher
(
"
/s
uccess"
);
dispatcher
.
forward
(
request
,
response
);
dispatcher
.
forward
(
request
,
response
);
}
else
{
}
else
{
//include
RequestDispatcher
rd
=
request
.
getRequestDispatcher
(
"login-try.html"
);
out
.
print
(
"Usuario invalido!"
);
rd
.
forward
(
request
,
response
);
RequestDispatcher
rd
=
request
.
getRequestDispatcher
(
"/login.html"
);
rd
.
include
(
request
,
response
);
}
}
}
}
@Override
public
void
doGet
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
RequestDispatcher
rd
=
request
.
getRequestDispatcher
(
"/login.html"
);
rd
.
forward
(
request
,
response
);
}
}
}
src/main/java/com/roshka/bootcamp/RequestDispatcherServletSuccess.java
View file @
808c1385
...
@@ -9,7 +9,7 @@ import jakarta.servlet.http.HttpServletResponse;
...
@@ -9,7 +9,7 @@ import jakarta.servlet.http.HttpServletResponse;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.io.PrintWriter
;
@WebServlet
(
"/
dispatcher
"
)
@WebServlet
(
"/
success
"
)
public
class
RequestDispatcherServletSuccess
extends
HttpServlet
{
public
class
RequestDispatcherServletSuccess
extends
HttpServlet
{
public
void
doPost
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
public
void
doPost
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
...
...
src/main/webapp/login-try.html
0 → 100644
View file @
808c1385
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
Login
</title>
<link
rel=
"stylesheet"
href=
"estilos/login.css"
></link>
</head>
<body>
<form
method=
"post"
action=
"login"
>
<h2
style=
"color:red;"
>
username o password invalido
</h2>
<label>
username:
</label>
<input
type=
"text"
name=
"username"
><br/>
<label>
password:
</label>
<input
type=
"password"
name=
"password"
><br/>
<input
type=
"submit"
>
</form>
</body>
</html>
\ No newline at end of file
src/main/webapp/login.html
View file @
808c1385
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
<form
method=
"post"
action=
"login"
>
<form
method=
"post"
action=
"login"
>
<label>
username:
</label>
<label>
username:
</label>
<input
type=
"text"
name=
"username"
><br/>
<input
type=
"text"
name=
"username"
><br/>
<label>
password:
</label>
<input
type=
"password"
name=
"password"
><br/>
<input
type=
"password"
name=
"password"
><br/>
<input
type=
"submit"
>
<input
type=
"submit"
>
</form>
</form>
...
...
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