Controller component responsible for processing the user request. It intercepting and translating user input into actions to be performed and receives the request from the browser, invoke a business operation and coordinating the view to return to the client.
The controller is implemented by a java servlet which is centralized point of control for the web application.
In struts framework ,There are several different components:-
1.ActionServlet Class :- It extends javax.servlet.http.httpServlet class.ActionServlet class is the controller components that handles clients requests and determine which Action will process the received request.You do not need to create a specialized controller implementation.
All incoming requests are mapped to the central controller :-
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
</servlet>
</web-app>
2. Action Class :-Action class must be extended for each specialized function in your application.
All types request with *.do are mapped to this servlet :-
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>