Get all updates of Java4s
Follow Us: Email Newsletter

Aware Interfaces of struts 2

Struts » On Oct 23, 2011 { 3 Comments } By Sivateja

In struts2 we don’t have any http specific objects by default just like in servlets.  If at all we want any http related objects in our Action class then we need to implement our Action class from Aware Interfaces provided by struts framework.

We can say here frame work using one form of dependancy injection of type interface for injecting required objects into an Action class of struts2.

Struts 2 provided total of 5 Aware Interfaces

  • ApplicationAware Interface
  • SessionAware Interface
  • ServletRequestAware Interface
  • ServletResponseAware Interface
  • ParameterAware Interface


Every Aware interface provides a setter method, so we must override that setter method while implementing the particular Aware interface, at run time struts 2 controller will automatically calls that setter method and injects the required object into that Action class



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.


3 Responses to “Aware Interfaces of struts 2”
  1. Abhishek Aggarwal says:

    ServletContextAware is not the part of Struts 2 Aware Interfaces?

  2. Java4s says:

    @Abhishek Aggarwal

    In fact we can get ServletContext object with ServletContextAware interface, in this case we have to call setServletContext() method.

    But sometimes ServletContextAware interface is not working properly,

  3. kishor says:

    ServletContextAware is not the part of Struts 2 Aware Interfaces?


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.