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 the Author .::

Java4s_Author
Sivateja Kandula - Java/J2EE Full Stack Developer
Founder of Java4s - Get It Yourself, A popular Java/J2EE Programming Blog, Love Java and UI frameworks.
You can sign-up for the Email Newsletter for your daily dose of Java tutorials.

Comments

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?

Name*
Mail*
Website



By posting your answer, you agree to our comments policy.
Most Recent Posts from Top Categories
Spring Boot Hibernate Spring
Contact | About Us | Privacy Policy | Advertise With Us

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