File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Spring and the fly likes Problems accessing ModelAttribute variable in JSP session. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Problems accessing ModelAttribute variable in JSP session." Watch "Problems accessing ModelAttribute variable in JSP session." New topic

Problems accessing ModelAttribute variable in JSP session.

Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1129

I have a simple

in my Spring 3 MVC controller. I have put an Iterator there to make sure that the userService.loadUsers() is actually populated.

(The loadUsers() method returns a Set.)


Now, in my listUsers.jsp page, I have JSTL like this (to try to set up a combo with a list of user names):


The problem is that the combo is empty -- it never gets populated.

In the debugger, it steps right over the code and doesn't loop as it should.

Therefore, I think I'm missing something basic here.

Isn't the object automatically in the JSP's "session". Do I need to do something special to access it?

Look forward to any suggestions.



guillermo luque

Joined: Aug 03, 2002
Posts: 10

First when you mentioned session you meant session scope. HTTPSESSION

I got a problem with sessions in Spring I posted see below

"Thursday, June 23, 2011 7:22:09 PM by guillermo luque Title Session in Spring" Please give your opinon
about my post.
If it is session scope let me tell you.

I was doing some research in sessions

let me ask a question

1.- I assume that you create the session before you run your jsp file and populated it
if you did you used HTTPSESSION or scope-sesion in the controller
if you use HTTPSESSION you need to carry over the session references over you application JSP does not carry over the session automatically when I was writing
app with servelet and jsp I put in all the JSP files

<jsp:useBean id="loginprocessor" class="com.luque.logged.beans.LoginProcessor" scope="application" />
<jsp:useBean id="userinfo" class="com.luque.logged.beans.UserInfo" scope="session" />

The session an application scope were created when the user sign in
But I was trying to use with spring and it did not work.

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Problems accessing ModelAttribute variable in JSP session.
jQuery in Action, 3rd edition