• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Pls help with HttpSession in SpringMVC Model

 
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a class extends Controller and return the ModelAndView
I want to somehow session the object that I invoke from the method that call the web-service. How or what i have to do. Here is the snipet code that I wrote

[code]
HttpSession session = request.getSession(true);
session.setAttribute("someString", this.getWebService()) // invoke a method to return a Collection from webservice
if (action == "none")
// in here i want to get the session and get the data again from the session?

ArrayList arrList = (ArrayList) session.get(someString)? // is this right?

Greatly appreciated with your help
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
//put something in the session
HttpSession session = request.getSession();
session.setAttribute("myIdentifier", myObject);

// get something out of the session

MyObject myObj = (MyObject) session.getAttribute("myIdentifier");

The only thing I saw in your code that looks odd is
if(action == "none")

If you're comparing 2 strings use the .equals()

if("none".equals(action)){
... do somethign here.
}
 
reply
    Bookmark Topic Watch Topic
  • New Topic