wood burning stoves 2.0*
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "JSP Watch "JSP New topic
Author

JSP's Java retrieve variable from Action class

wai chun chor
Greenhorn

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

JSP:
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
Bartender

Joined: Oct 29, 2001
Posts: 8836
    
    7

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]
 
I agree. Here's the link: http://aspose.com/file-tools
 
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?