• 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

Spring MVC Issue: Passing data to view

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to pass data from the Controller to view (jsp page) using ModelAndView object. Please consider the following code,

home.jsp
--------
<html>
.
.
<p>${message}</p>
.
</html>

Controller Class
----------------
public class UAMInternalController implements Controller {

protected final Log logger = LogFactory.getLog(getClass());
private String greeting = "Namaste!";
.
.

public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
.
.
return new ModelAndView("home","message", greeting);
}
}


The view is printing the variable as is, that is, ${message} instead of the contents of the variable "greeting". Please suggest a solution for this problem.

Thanks,
Swamy
SCJP 1.2, SCWCD, SCBCD
 
Balaji Akella
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I figured out the problem, but not the reason though..

The JSP was changed to use, JSTL tags, in which case it works. The new JSP file looks something like this:

<%@ taglib prefix="core" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
.
.
<core ut value="${message}"/>
.

Thanks,
Swamy
reply
    Bookmark Topic Watch Topic
  • New Topic