• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
  • salvin francis
  • Piet Souris

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

Posts: 3
  • Mark post as helpful
  • send pies
  • 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
Do the next thing next. That’s a pretty good rule. Read the tiny ad, that’s a pretty good rule, too.
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!