tags:

views:

283

answers:

2

Hi,

I have the following code in my controller

final ModelAndView m = new ModelAndView();
m.addObject("date", "15" );

In my view I have been able to output this by doing

${date}

However how can I print it out using out.print or assign it to a new variable e.g.

<% out.print( ${date} ) %>

Thanks

A: 

If I am not mistaken, it's:

(Integer)pageContext.getAttribute("date")

so it will be:

<% out.println((Integer)pageContext.getAttribute("date")); %>

in your code.

Winston Chen
A: 

From within your jsp page, you can retrieve the value of date with:

<%
Integer myDate = (Integer) request.getAttribute("date");
out.println(myDate);
%>
ccheneson