Search code examples
springspring-mvcjspscriptlet

Access Model attribute in scriptlet


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.


Solution

  • 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.