In Java EE, we often use ActionContext,ServletContext and ServletActionContext, they have similar name, but I don't know the difference between them.
I only know the ServletActionContext inherit the ActionContext.
Someone can explain them?
There have many difference between them.
ServletContext
From the
ServletContext's package(javax.servlet.ServletContext) we can know it is standard JavaEE WebApplication class library.ServletContext provides the standard Servlet run-time environment. Actually is some methods of servlet communicate with web container.
ServletContext is included in the ServletConfig, and ServletConfig often read from servlet or filter's
init()method:ActionContext
Comes from Struts, but at first comes from Struts1 and Struts2 they are different.
From Struts1:
A
servlet(servlet org.apache.struts.action.ActionServlet) handle all the*.doaction.From Struts2:
The
filter(org.apache.struts2.dispatcher.FilterDispatcher) handle all the request.Because struts1 belongs to servlet scope. struts1 action's essentially is servlet.
struts2 action is normal Java bean, out of the servlet limitations.
The ActionContext makes up the lost WEB environment after the strtus2 action out of the stand servlet framework.
The ActionContext main function:
ServletActionContext
As you say, ServletActionContext is ActionContext's subclass. Its functions is starting at ActionContext, and encapsulate the methods, make it more simple and intuitive.
We can also study its source code:
From above we can know the ServletActionContext extends ActionContext.