Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between ServletContext and ServletActionContext

Please tell me what is the difference between ServletActionContext and ServletContext? ServletContext is shared among all the servlets and actions, while ServletActionContext is specific to an action or is that also shared among all the actions?

like image 325
user1147070 Avatar asked Jul 27 '13 09:07

user1147070


People also ask

What is the difference between ServletContext and ServletConfig objects?

The servletconfig object refers to the single servlet whereas servletcontext object refers to the whole web application. ServletConfig is implemented by the servlet container to initialize a single servlet using init(). That is, you can pass initialization parameters to the servlet using the web.

What is ServletActionContext?

The ServletActionContext class provides methods to get HttpServletRequest, HttpServletResponse, ServletContext and HttpSession objects. It is a convenient class and prefered than ActionContext class.

What is ServletConfig and ServletContext explain with example?

ServletConfig is servlet specific. ServletContext is for whole application. Parameters of servletConfig are present as name-value pair in <init-param> inside <servlet>. Parameters of servletContext are present as name-value pair in <context-param> which is outside of <servlet> and inside <web-app>

Why do we use ServletContext?

The ServletContext object can be used to get configuration information from the web. xml file. The ServletContext object can be used to set, get or remove attribute from the web. xml file.


1 Answers

These are different things. ServletContext is a servlet related, ActionContext is Struts 2 action related, ServletActionContext extends ActionContext but in major it's an utility class.

If you want to know what is the actioncontext.

like image 62
Roman C Avatar answered Oct 29 '22 15:10

Roman C