Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
ProyectoFinal-Bootcamp
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
Jose Baez
ProyectoFinal-Bootcamp
Commits
35b9138f
Commit
35b9138f
authored
May 12, 2022
by
Emanuel Lugo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
login parcial
parent
f1f3ee4e
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
120 additions
and
1 deletions
+120
-1
.idea/encodings.xml
+2
-0
src/main/java/com/roshka/proyectofinal/entity/LoginBean.java
+22
-0
src/main/java/com/roshka/proyectofinal/login/LoginDao.java
+33
-0
src/main/java/com/roshka/proyectofinal/login/LoginServlet.java
+62
-0
src/main/webapp/login.jsp
+1
-1
No files found.
.idea/encodings.xml
View file @
35b9138f
...
...
@@ -2,5 +2,6 @@
<project
version=
"4"
>
<component
name=
"Encoding"
>
<file
url=
"file://$PROJECT_DIR$/src/main/java"
charset=
"UTF-8"
/>
<file
url=
"file://$PROJECT_DIR$/src/main/resources"
charset=
"UTF-8"
/>
</component>
</project>
\ No newline at end of file
src/main/java/com/roshka/proyectofinal/entity/LoginBean.java
0 → 100644
View file @
35b9138f
package
com
.
roshka
.
proyectofinal
.
entity
;
public
class
LoginBean
{
private
String
username
;
private
String
password
;
public
String
getUsername
()
{
return
username
;
}
public
String
getPassword
()
{
return
password
;
}
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
}
src/main/java/com/roshka/proyectofinal/login/LoginDao.java
0 → 100644
View file @
35b9138f
package
com
.
roshka
.
proyectofinal
.
login
;
import
com.roshka.proyectofinal.DataBase
;
import
com.roshka.proyectofinal.entity.Lenguaje
;
import
com.roshka.proyectofinal.entity.LoginBean
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
public
class
LoginDao
{
public
boolean
validate
(
LoginBean
loginBean
)
{
int
status
=
0
;
try
{
Connection
con
=
DataBase
.
getConnection
();
PreparedStatement
ps
=
con
.
prepareStatement
(
"select * from usuarios where username=? and password = ?"
);
ps
.
setString
(
1
,
loginBean
.
getUsername
());
ps
.
setString
(
2
,
loginBean
.
getPassword
());
status
=
ps
.
executeUpdate
();
con
.
close
();
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
}
if
(
status
>
0
)
return
true
;
else
return
false
;
}
}
src/main/java/com/roshka/proyectofinal/login/LoginServlet.java
0 → 100644
View file @
35b9138f
package
com
.
roshka
.
proyectofinal
.
login
;
import
java.io.IOException
;
import
jakarta.servlet.ServletException
;
import
jakarta.servlet.annotation.WebServlet
;
import
jakarta.servlet.http.HttpServlet
;
import
jakarta.servlet.http.HttpServletRequest
;
import
jakarta.servlet.http.HttpServletResponse
;
import
com.roshka.proyectofinal.entity.LoginBean
;
/**
* Servlet implementation class LoginServlet
*/
@WebServlet
(
"/login"
)
public
class
LoginServlet
extends
HttpServlet
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* @see HttpServlet#HttpServlet()
*/
public
LoginServlet
()
{
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
{
LoginDao
loginDao
=
new
LoginDao
();
String
username
=
request
.
getParameter
(
"username"
);
String
password
=
request
.
getParameter
(
"password"
);
LoginBean
loginBean
=
new
LoginBean
();
loginBean
.
setUsername
(
username
);
loginBean
.
setPassword
(
password
);
if
(
loginDao
.
validate
(
loginBean
))
{
response
.
sendRedirect
(
"loginSuccess.jsp"
);
}
else
{
//HttpSession session = request.getSession();
response
.
sendRedirect
(
"login.jsp"
);
}
}
}
\ No newline at end of file
src/main/webapp/login.jsp
View file @
35b9138f
...
...
@@ -11,7 +11,7 @@
<table>
<tr><td>
User Name:
</td>
<td><input
type=
"text"
name =
"username"
></td></tr>
<tr><td>
Password:
</td><td><input
type=
"password"
name=
"password"
></td></tr>
<tr><td><
/td>
<td></td><input
type=
"sumbmit"
value=
"Login"
></td></tr>
<tr><td><
input
type=
"submit"
value=
"Login"
/
></td></tr>
</table>
</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