in struts how can i set/get application value?

Posted on 2004-08-17
Last Modified: 2012-05-05
hi,experts now i hava a struts page like this
,how can i get the application value???
      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.
Question by:hgbdelphi
  • 2

Author Comment

ID: 11818678
i can set session like this in Struts's action

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

thanks very much!

Expert Comment

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: 
the classname is  org.apache.struts.taglib.tiles.util.TagUtils

Accepted Solution

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

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


Author Comment

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


Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
getting Http 404 error in jsp forms 8 73
java cigar challenge 58 206
Can't access image with tomcat/html 6 95
mask rule in struts validation.xml 5 85
There are many Password Managers (PM) out there to choose from. PM's can help with your password habits and routines, but they should not be a crutch you rely on too heavily. I also have an article for company/enterprise PM's.
Knowledge base software has turned out to be a quite reliable method for storing information, promoting collaborative work and for sharing valuable input and solutions.However, some organizations are trying to develop a knowledge base that works wit…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: (…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

896 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now