Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 927861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:55:11+00:00 2026-05-15T19:55:11+00:00

I have a login and a user info page which is displayed after login.

  • 0

I have a login and a user info page which is displayed after login. How can I block user info page from direct access by user? How can I implement that with session?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T19:55:12+00:00Added an answer on May 15, 2026 at 7:55 pm

    At login time, put the found User object in the session.

    String username = request.getParameter("username");
    String password = request.getParameter("password");
    User user = userDAO.find(username, password);
    if (user != null) {
        request.getSession().setAttribute("user", user);
        response.sendRedirect("secured/userpage");
    } else {
        request.setAttribute("error", "Unknown username/password combo, please try again");
        request.getRequestDispatcher("/WEB-INF/login.jsp").forward(request, response);
    }
    

    Then implement a Filter which just checks the presence of the logged-in user in the session.

    if (((HttpServletRequest) request).getSession().getAttribute("user") != null) {
        chain.doFilter(request, response); // Logged in, so just continue.
    } else {
        response.sendRedirect("login"); // Not logged in, redirect to login page.
    }
    

    Map this filter on an URL pattern of /secured/* (or anything else whatever you want) and put the secured pages like the user info page in the same folder.

    To logout a user, just do session.removeAttribute("user") or, more drastically, session.invalidate().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have created one login and register view in that view after login user
I have a Login page that captures User input like this. MD5calc ss =
I have a login form that has Username and password as inputs from user
I have a Login dialog that can create an alert dialog when the user
I have a simple authorization page which intends the user to type login and
I have created a login page which authenticates a user via the atuthentication class.
I have a login page which has two options login as guest , login.
I have a web application that begins with a login page. During the verification
Why drop down menu not showing ID from database? I have login page. when
I have a navigation bar that displays login and register when the user is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.