• 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 ...
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown

Want to use Session Variable for my login form in Spring MVC 3

Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My Controller:

public class ArticleController {
private ArticleService articleService;

@RequestMapping(value = "/save", method = RequestMethod.POST)
public ModelAndView saveArticle(@ModelAttribute(" article ") Article article,
BindingResult result) {
ModelAndView modelAndView = new ModelAndView();

modelAndView.addObject("user_sess",article.getUser ());
System.out.println("article.getUser()"+article.get User());
articleService.addArticle( article);

// session.setAttribute("user_Sess", article.getUser());
// return new ModelAndView("redirect:/articles.html");
return new ModelAndView("Welcome");

@RequestMapping(method = RequestMethod.GET)
public ModelAndView listArticles() {
Map<string,> model = new HashMap<string,>();
model.put("articles", articleService.listArticles());

return new ModelAndView("articlesList", model);

@RequestMapping(value = "/add", method = RequestMethod.GET)
public ModelAndView addArticle(@ModelAttribute("article") Article article,
BindingResult result) {
return new ModelAndView("addArticle");

In Jsp page Welcome.jsp :

Welcome: ${user_sess}

//Dont know how to use session variable because value is not received in jsp page.It is a simple spring mvc 3 hibernate project using database mysql. Please help me
    Bookmark Topic Watch Topic
  • New Topic