Access Model attribute in scriptlet

Saket picture Saket · Nov 13, 2011 · Viewed 17.8k times · Source

I am using Spring MVC, and in my Controller, I am setting a standard model attribute using:

...
model.addAttribute("param", value);
...

Now, I wish to access this in a scriptlet (within a JSP). For example:

<% 
Object value = ***.get***("param"); 
... more java code...
%>

How can I do this?

NOTE: I understand it is a BAD IDEA to use scriptlets, but please bear with it for now.

Answer

BalusC picture BalusC · Nov 13, 2011

It's stored as a request attribute.

Object param = request.getAttribute("param");

Unrelated to the concrete problem, I suggest to ask a new question wherein you ask how to achieve the functional requirement without the need to fall back to legacy practices.