I have website project .user can log in to use it at the home page
now the problem is if any user write URL for any other page without login it will show him the page I need to ensure that any user visit other page have already logged in AT THE HOME PAGE
I USED JSP MYSQL JS CSS HTML

You can do it using C taglib library.
C taglib library give you if, when, for, while loops so you can use it in .jsp pages so you will just need if in C taglib it is called: choose
To use C taglib just put this in top of your page:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

In you servlet where you check login of user you can add field to session to set userLogedIn = true;

boolean userLogedIn = true;
request.getSession().setAttribute("userLogedIn", userLogedIn);

Then on every page you will have something like this:

<c:choose>
    <c:when test="${userLogedIn}">
    // HTML YOU WANT TO SHOW WHEN USER IS LOGED IN!!!
    </c:when>
    <c:otherwise>
        PLEASE LOGIN!!!
    </c:otherwise>

</c:choose>

When you logout just delete this from session and that is it.
Every user will have thier own session so you don't need to wory about anything...
You can find a lot of examples on this link.
I hope this will help you. If you have any questions feel free to ask.
Regards, Mike.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.