?
Solved

Spring MVC - access model attributes inside a scriplet

Posted on 2011-03-10
5
Medium Priority
?
2,199 Views
Last Modified: 2012-05-11
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
Comment
Question by:lotrzz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 

Author Comment

by:lotrzz
ID: 35095326
I meant, If I do  <c:out value="${model.attr1}"/>  in jstl,  I can see the value.
0
 

Author Comment

by:lotrzz
ID: 35096157
Any help would be appreciated
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 35097535
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
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 35097549
String attr1Val = (String)request.getAttribute("model.attr1");
0
 
LVL 92

Accepted Solution

by:
objects earned 200 total points
ID: 35099680
> return new ModelAndView("view1", "model", model);

change that to:


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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month10 days, 8 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question