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

  • Home
  • SEARCH
  • 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 6042431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:47:23+00:00 2026-05-23T06:47:23+00:00

I understand how to access Session attributes using EL in my JSP/Servlet application: <p>

  • 0

I understand how to access Session attributes using EL in my JSP/Servlet application:

    <p> Hello <c:out value="${sessionScope.userName}"/> </p>

However, I was wondering if there was a way to hide a Session variable from JSP page EL access? If I set a session variable in my servlet, such as:

    UserDAO user = new UserDAO();
    user.setUserName("XYZ");
    request.getSession().setAttribute("user", user);

Is there a way to prevent that UserDAO Java Object’s fields from being accessed on the JSP with some code such as:

    <p> Hello <c:out value="${user.userName}"/> </p>

Thank you.

  • 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-23T06:47:24+00:00Added an answer on May 23, 2026 at 6:47 am

    There isn’t. At least, not without writing a custom EL resolver which isn’t exactly trivial.

    Your best bet is to wrap it in an object which does not expose the value by a Javabean getter method. E.g.

    public class UserWrapper implements Serializable {
    
        private User user;
    
        public UserWrapper(User user) {
            this.user = user;
        }
    
        public User get() {
            return user;
        }
    
    }
    

    Store it in the session as follows instead.

    session.setAttribute("user", new UserWrapper(user));
    

    Get it from the session as follows instead.

    User user = ((UserWrapper) session.getAttribute("user")).get();
    

    This method is inaccessible in EL. At least, in EL versions prior 2.2 where you could otherwise just do #{user.get()}.

    Alternatives are to make the getter method of the wrapper class package-protected so that it’s only accessible by classes in the same package and/or subclasses (EL namely requires it to be public).

        protected User get() {
            return user;
        }
    

    Or even make the whole wrapper class a private or package-protected inner class.

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

Sidebar

Related Questions

I don't understand Access Modifiers in OOP. Why do we make for example in
I understand what it means to access memory such that it is aligned but
I understand the many benefits of providing an interface to access the members of
I'm trying to access my class's private enum. But I don't understand the difference
In what cases is it necessary to synchronize access to instance members? I understand
I'm trying to make this 2-player web game application using Spring MVC. I have
(I think) I understand why session IDs should be rotated when the user logs
I am trying to simulate a session using FactoryGirl / shoulda (it worked with
How can I access a user session objects from another thread? I want to
I am using Apache Shiro in a web-application. The login and authentication check works

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.