Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 340
  • Last Modified:

in struts how can i set/get application value?

hi,experts now i hava a struts page like this
,how can i get the application value???
thanks!
      public ActionForward execute(
            ActionMapping mapping,
            ActionForm form,
            HttpServletRequest request,
            HttpServletResponse response)
            throws Exception {
                        //in servlet i can do this get the application "application" value,but when i use struts,how can i get the application value???
            //getServletContext().setAttribute("application","testvalue");  //can get application value in servlet,but not get value in it.
      }
0
hgbdelphi
Asked:
hgbdelphi
  • 2
1 Solution
 
hgbdelphiAuthor Commented:
i can set session like this in Struts's action
      request.getSession().setAttribute("aa","test")

but how can i set application in Sturts 's action??

thanks very much!
0
 
Oliver_DornaufCommented:
struts comes with a class TagUtils wich have your function. (or you can study the source if you need a diffrent implementation)

look at: http://struts.apache.org/api/index.html 
the classname is  org.apache.struts.taglib.tiles.util.TagUtils
0
 
sbockelmanCommented:
in the action you can do what you want like this:

getServlet().getServletContext().getAttribute( "foo" )

0
 
hgbdelphiAuthor Commented:
thank for your help,
hi,sbockelman ,your code can help me ,thank!

0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now