Reputation: 13
i design a jsp page but i want only some one that login as member of my site(have session with some futures) see that page and if some one that is not member try to see page refer to a custom eror page.can you advise me something helpfull?
<%@ 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=ISO-8859-1">
<title> User Account</title>
</head>
<body>
<%@include file="Header.jsp" %>
${welcome } ${name} ${family }
</body>
</html>
any help fall me in greatfull...
Upvotes: 0
Views: 145
Reputation: 597076
Use a servlet filter.
javax.servlet.Filter
. Call chain.doFilter(..)
only if you find a user in the session; otherwise call response.sendRedirect("notLoggedIn.jsp");<filter>
and <filter-mapping>
) (or if you are using servlet 3.0 - use @WebFilter
on the filter class). Map the filter to the path(s) you want to protect.Upvotes: 1