0
What verification should I do if the user directly accesses the home.jsp page without logging in? Noting that I am not using Servlet for this situation, only jsp pages.
Code from home.jsp page:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Bem vindo</title>
</head>
<body>
<%
if ((session.getAttribute("login").equals(null)) || (session.getAttribute("login").equals(""))) {
%>
Você não esta logado. <a href="index.jsp">Por favor, entre com a sua conta.</a>
<%
} else {
%>
Seja bem vindo,
<%=session.getAttribute("login")%>
<center>
<a href="http://localhost:8080/Atividade07/listUsers">Listar -
Servlet</a><br> <a href="listar.jsp">Listar - JSP</a><br> <a
href='logout.jsp'>Log out</a>
</center>
<%
}
%>
</body>
</html>
Code of login.jsp page:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Login</title>
</head>
<body>
<form action="checklogin.jsp" method="post">
<center>
<table border="1" width="30%" cellpadding="3">
<thead>
<tr>
<th colspan="2">Login</th>
</tr>
</thead>
<tbody>
<tr>
<td>Login</td>
<td><input type="text" name="login"/></td>
</tr>
<tr>
<td>Senha</td>
<td><input type="password" name="senha"/></td>
</tr>
<tr>
<td><input type="submit" value="Login" /></td>
<td><input type="reset" value="Reset" /></td>
</tr>
<tr>
<td colspan="2">Ainda não esta cadastrado? <a href="register.jsp">Cadastra-se</a></td>
</tr>
</tbody>
</table>
</center>
</form>
</body>
</html>
Clarifying further the context of this application follows an image of the application, which should implement the figure below (Only the part that is highlighted).
Vitor Oliveira, I believe the answer: here may help in understanding your question.
– pss1suporte