File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes JSP's Java retrieve variable from Action class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "JSP Watch "JSP New topic

JSP's Java retrieve variable from Action class

wai chun chor

Joined: Sep 28, 2011
Posts: 2
Action Class:
say I have an action class with variable integer "totalUsers" set to 40.

I have no problem retrieving this value via Struts tag such as:

The code above works fine.

But how do I get this value via Java code inside my JSP file?
Joe Ess

Joined: Oct 29, 2001
Posts: 8843

Welcome to the JavaRanch.
First, you should reconsider. Using Java in a JSP a sign that you are putting logic in the display tier.
That said, you can get to the Action via the ValueStack, which you can obtain from the static method in ServletActionContext

"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
jQuery in Action, 2nd edition
subject: JSP's Java retrieve variable from Action class
Similar Threads
Need value from <s:property> to JSP variable
how to pass value from action to jsp scriplet
struts-2 (set values to action class)
Scope in JSTL
way to assign value from struts property to java variable?