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
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: 9189

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

[How To Ask Questions On JavaRanch]
I agree. Here's the link:
subject: JSP's Java retrieve variable from Action class
It's not a secret anymore!