Get all updates of Java4s
Follow Us: Email Newsletter

Example on ApplicationAware Interface of struts 2

Struts » On Oct 24, 2011 { 7 Comments } By Sivateja

So ApplicationAware interface, we need to implement our Action class from ApplicationAware interface when ever our Action class need to get context behavior, means we can share our data across all the files of the web application by putting in a global object that’s context :-)

When we implement our Action class from ApplicationAware interface then the controller doesn’t inject exactly servlet context object, instead it will injects a map object and this will created once by the controller and the same object will be injected to all files of the struts application.

Example on struts 2 ApplicationAware

files we used…

  • index.jsp
  • error.jsp
  • success.jsp
  • [ in java4s package ]
  • web.xml [ in web-inf ]
  • struts.xml [ in web-inf/classes folder ]

Directory Structure





After Execution


You Might Also Like

  ♦ About Author ♦

Full Stack( Java/J2EE & UI/UX ) Developer and founder of Java4s - Get It Yourself, A popular Java/J2EE Programming Blog. Sign-up for the Email Newsletter for your daily dose of Java tutorials.


7 Responses to “Example on ApplicationAware Interface of struts 2”
  1. Mohammed Vaseem says:

    Am getting exception in this program. Usually the exception messages will be displayed on the console and as well as on the browser. But am seeing this first time that, the exception messages are displaying on the browser but in console screen alike messages are displayed. Please provide the reason.

    When I was tracing the program, I got to know exception was coming at line 44 of program.

    The browser exception messages are
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    java.lang.reflect.Method.invoke(Unknown Source)

  2. Java4s says:


    Its working fine from my end,any ways try these…

    – Make sure you download the program [ Click on Download button ]
    – If you copy the source code from the web page, while pasting the code it will prints some other characters in place of quotes.
    – If you copy, just remove all the double quotes and insert again manually.

    try finally..!!

  3. Abhishek says:

    Hey when i run this demo it will not show proprety value of my successfull pgae please help me where i am getting wrong in this

  4. Java4s says:


    Make sure you are writing #application.keys in your map object.

    Download the program and check again and lemme know.

  5. sanjeev kumar says:

    what is Value stack, Action context,and Action Invocation in struts2?

  6. Raghu says:


    This Program is very useful to get knowledge about applicationaware interface.But what is the difference between applicationaware and session?

    1.Can i use applicationaware instead of session to store User infomation on login session?

  7. asif says:

    Thanqqqqqqqqqqqqqqqqq its simply supeb to learn


By posting your answer, you agree to our comments policy.
What would you like to learn today?
Browse these popular technologies
Hibernate spring struts Servlets ajax Log4j jQuery Json Core Java Web Services AngularJs
Most Recent Tutorials
Hibernate_Logo Hibernate Recent Posts Spring_Logo Spring Recent Posts Struts_Logo Struts Recent Posts
Useful Links Current & UpComing Tutorials
  Web Services [ SOAP ], JSP
Contact | About Us | Privacy Policy | Advertise With Us

© 2010 - 2016 Java4s - Get It Yourself.
The content is copyrighted to Sivateja Kandula and may not be reproduced on other websites.