Solved

in struts how can i set/get application value?

Posted on 2004-08-17
4
329 Views
Last Modified: 2012-05-05
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
Comment
Question by:hgbdelphi
  • 2
4 Comments
 

Author Comment

by:hgbdelphi
ID: 11818678
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
 
LVL 4

Expert Comment

by:Oliver_Dornauf
ID: 11819069
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
 
LVL 3

Accepted Solution

by:
sbockelman earned 50 total points
ID: 11823567
in the action you can do what you want like this:

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

0
 

Author Comment

by:hgbdelphi
ID: 11826613
thank for your help,
hi,sbockelman ,your code can help me ,thank!

0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need to view directory list in apache/tomcat 9 114
getting Http 404 error in jsp forms 8 77
caughtSpeeding java challenge 16 136
nested if has else if 13 94
Learn how the use of a bunch of disparate tools requiring a lot of manual attention led to a series of unfortunate backup events for one company.
Read about the ways of improving workplace communication.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question