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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:29:40+00:00 2026-06-10T10:29:40+00:00

Doing a web site using spring mvc. I added a SignupController to handle all

  • 0

Doing a web site using spring mvc. I added a SignupController to handle all the sign up related requests. Once user signup I am adding that to a session using @Scope(“session”). Below is the SignupController code,

SignupController.java

@Controller
@Scope("session")
public class SignupController {

@Autowired
SignupServiceInter signUpService;

private static final Logger logger = Logger.getLogger(SignupController.class);

private String sessionUser;

@RequestMapping("/SignupService")
public ModelAndView signUp(@RequestParam("userid") String userId, 
    @RequestParam("password") String password,@RequestParam("mailid") String emailId){

    logger.debug("  userId:"+userId+"::Password::"+password+"::");

    String signupResult;

    try {

        signUpService.registerUser(userId, password,emailId);
        sessionUser  = userId; //adding the sign up user to the session
        return new ModelAndView("userHomePage","loginResult","Success"); 
         //Navigate to user Home page if everything goes right

    } catch (UserExistsException e) {
        signupResult = e.toString();
        return new ModelAndView("signUp","loginResult", signupResult); 
         //Navigate to signUp page back if user does not exist
    }
}
 }

I am using “sessionUser” variable to store the signed up User Id. My understanding is that when I use @Scope(“session”) for the controller all the instance variables will added to HttpSession. So by that understanding I tried to access this “SessionUser” in userHomePage.jsp as,

userHomepage.jsp

Welcome to <%=session.getAttribute("sessionUser")%>

But it throws null.

So my question is how to use the values from session variables in jsp pages that got saved using @Scope(“session”) in the mvc controllers.

Note: My work around is that pass that signed User Id to jsp page through ModelAndView, but it seems passing the value like these among the pages takes me back to managing state among pages using QueryStrings days.

  • 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-06-10T10:29:41+00:00Added an answer on June 10, 2026 at 10:29 am

    When you specify @Scope(“session”) for the controller, Spring will now ensure that there is a unique instance of the controller for every session, and so you will be able to keep a session specific state like sessionUser as a instance variable.

    However to expose a variable to the UI, that variable has to be a part of the model/session attributes, you can do that either with @ModelAttribute(“sessionUser”) or @SessionAttribute(“sessionUser”)

    @Controller
    @SessionAttribute("sessionUser")
    public class SignupController {
    @RequestMapping("/SignupService")
    public ModelAndView signUp(@RequestParam("userid") String userId, 
        @RequestParam("password") String password,@RequestParam("mailid") String emailId,  Model model){
    ...
        try {
    
            signUpService.registerUser(userId, password,emailId);
            sessionUser  = userId; //adding the sign up user to the session
            model.addAttribute("sessionUser", sessionUser);
    
            return new ModelAndView("userHomePage","loginResult","Success"); 
             //Navigate to user Home page if everything goes right
           ....
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing a web site using spring mvc framework. I want to do
I'm doing a Web application using Spring 3.1.0.RELEASE, JSF 2.x, JPA 2 with Hibernate
This is my first time doing VB :-) I've inherited a web site, which
I'm doing a simple news importer for a sharepoint site using timer job that
Here's the situation: the user is able to sign into a MVC application from
I'm using the following code to make HttpWebRequests to a web site: public static
Hello, I am doing a website using drupal 7 and I do the registration
i am doing a mobile version of a website using JQuery Mobile and JSON
Our website runs the user's input via HtmlTidy to clean it. Apparently while doing
I'm doing the migration of a site, from MovableType to WordPress. The website contain

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.