File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes how to insert static variable with struts tags 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 "how to insert static variable with struts tags" Watch "how to insert static variable with struts tags" New topic
Author

how to insert static variable with struts tags

Shankar Narayana
Ranch Hand

Joined: Jan 08, 2003
Posts: 134
Hi,

Is there any way I can use the struts tag library to put the value of a static variable in the jsp.

for ex:


I want to put the value of REQUEST_TYPE in the jsp, how?


"Failure is not when you fall down; its only when you fail to get up again."
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30136
    
150

Shankar,
There are two ways of doing this, both a bit messy:

1) Use a partial scriptlet:
<bean efine id="staticField" value="<%= new String(ReqSessConstants.REQUEST_TYPE) %>" />
<bean:write name="staticField" />

2) Wrap the constant in a getter method of a bean.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to insert static variable with struts tags
 
Similar Threads
JSP in Struts
Pass a Variable from JSP via JSP to an Action Servlet
assign return value of function from javascript to variable in jsp
variable in scriplet and declaration
Function call inside struts tags