Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Spring MVC - access model attributes inside a scriplet

Posted on 2011-03-10
5
Medium Priority
?
2,296 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

610 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