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 3608754
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:32:27+00:00 2026-05-18T21:32:27+00:00

I make (thanks with some users on this portal) my application that implements SessionAware.

  • 0

I make (thanks with some users on this portal) my application that implements SessionAware.

This is my actual code :

public class UserManager extends ActionSupport implements SessionAware {
    private Map<String, Object> session;

    @Override
    public String execute() throws Exception {
        return SUCCESS;
    }

    public void setSession(Map<String, Object> map) {
        this.session=map;
    }

    public String checkLogin() {        
        session.put("loggedOn", true);
        return SUCCESS;
    }

    public String checkLogout() {
        session.clear();
        return SUCCESS;
    }
}

And i check these variables on my .jsp :

<s:if test="#session['loggedOn']!=true">
    DIV LOGIN
</s:if>
<s:else>
    DIV LOGOUT
</s:else>

An easy piece of code.

What i’d like to know is this :

1 – the bean is (as default) request scoped. So when the request is finished it will be destroyed. But i see that, when i put a variable in the Map, it still alive on the server. How is possible? Is a variable of my Bean.

2 – Who call the setSession method? I think the servlet, due to the fact I implements that interface?

3 – I would like to detach about saving object/bean on a Session Object. I’d like to use the Bean session scoped (as for any kind of MVC framework). How can I do it on struts2?

Hope you can make clear these questions 🙂 Cheers

  • 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-18T21:32:28+00:00Added an answer on May 18, 2026 at 9:32 pm

    1) Your bean is a struts2 action as such it is action scoped (which is a more restrictive scope than request). I say that action is a lesser scope because you can forward an action to another action in which case the previous action goes out of scope, request scoped objects however will stay in scope until the request is served. When you implement SessionAware you are provided with a reference to the SessionObject you are then putting your object into the Session object who’s life span is much longer than your action. Clear your browser cache will remove the session value… you can also remove them by code be implementing SessionAware and removing the value from the map.

    2 – The session already exists. You can get the session and add keys but even if you don’t put anything in it, it will be there for use.

    3 – You have a later question already for this topic see my answer there.

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

Sidebar

Related Questions

Now that I can make useful user controls in WPF (thanks to this stackoverflow
Thanks for reading this I thought I could use find(), but couldn't make it
To make a JavaScript class with a public method I'd do something like: function
I've worked on a number of products that make use of code generation. It
Thanks for reading. I'm a bit new to jQuery, and am trying to make
Make a new AS3 Document in Flash, paste in the following code and run
Our web application renders fast in some IE browsers, slow in others... It seems
make is not only useful for building your programming project, but it seems to
To make it short: hibernate doesn't support projections and query by example? I found
To make things easier when switching between machines (my workstation at the office and

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.