Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2465
  • Last Modified:

Spring MVC - access model attributes inside a scriplet

how do I get model attributes inside a scriplet tags in a jsp?

In my controller, I am setting the model attributes
model.setAttribute("attr1", attrVal1);
....

return new ModelAndView("view1", "model", model);

In view1.jsp,  I have

<%
String attr1Val = (String)request.getAttribute("attr1");

%>


The attr1Val is coming as null , what am I missing?  However, if i do  <c:outvalue="$model.attr1"/>  in jstl,  I can see the value.
0
lotrzz
Asked:
lotrzz
  • 2
  • 2
1 Solution
 
lotrzzAuthor Commented:
I meant, If I do  <c:out value="${model.attr1}"/>  in jstl,  I can see the value.
0
 
lotrzzAuthor Commented:
Any help would be appreciated
0
 
Sathish David Kumar NCommented:
What is value for attrVal1?  why set that in model directly set that value in request parameter then only you can get the value  

String attr1Val = (String)request.getAttribute("attr1");

but your setting in model so you cant get the value directly !

0
 
Sathish David Kumar NCommented:
String attr1Val = (String)request.getAttribute("model.attr1");
0
 
objectsCommented:
> return new ModelAndView("view1", "model", model);

change that to:


return new ModelAndView("view1", model);
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now