Struts 2 - Getting values from action in JSP pages using scriplet?
Swerrgy Smith
Ranch Hand
Joined: Mar 26, 2010
Posts: 49
posted
0
Dear all,
I have a property in an action class. How can I get its value in JSP pages without using Struts tag (like s:property etc.)?
For example, how can I print it value using scriplet like this: <% String s = request.getAttribute("myAttribute"); out.println("This is my string " + s); %>
I tried this code but it doesn't work. In which scope (request, session, application ...) is my property stocked?
^^
If you redirect the page, then a new request would be passed as a result. You better try with session scope. And i didn't know why you wanna use ugly scriptlets inside JSP?
Never try to be a hard-worker. Be a smart-worker.
My Blog
Swerrgy Smith
Ranch Hand
Joined: Mar 26, 2010
Posts: 49
posted
0
Rajkumar balakrishnan wrote:^^
If you redirect the page, then a new request would be passed as a result. You better try with session scope. And i didn't know why you wanna use ugly scriptlets inside JSP?
Dear Rajkumar,
Thank you very much. I just want to try another method. Furthermore, I don't understand how this property is pass from action class to JSP page? In which scope is it stocked (request, session, application ...) ?
Get a reference to the value stack, it's in the request.
I don't know why you'd want to do this either, but that's what you'd need to do.
Swerrgy Smith
Ranch Hand
Joined: Mar 26, 2010
Posts: 49
posted
0
David Newton wrote:Get a reference to the value stack, it's in the request.
I don't know why you'd want to do this either, but that's what you'd need to do.
Hello David,
Does that mean the property is neither in request, nor in session/application scope?
(I used to think that every object must be stored in request/session/application scope.)