In a servlet, you can write as follows
HttpSession session = request.getSession(true); session.setAttribute("firstName", customer.getFristName()) response.sendRedirect("index.jsp");
request.getSession(true) returns a new session if no sessions exist, otherwise it will return the current session. And on the index.jsp page index.jsp you can do the following:
<% if(session.getAttribute("firstName")==null) { %> <jsp:include page="firstPage.html"></jsp:include> <% } else { %> <jsp:include page="secondPage.html"></jsp:include> <% }%>
Here, if firstName is null, then firstPage.html will be included in the page, otherwise secondPage.html .
Visruth
source share