In legacy application: Implementing new module using struts as controller
Question
As of now my Java EE application controller is build using Http Serlvets for 8 modules
And there is a new module to be added, can I build this new module container using struts1?
What I believe is, this is possible, as these modules are using the front controller pattern for each module. And as I add new module, I can configure it using my struts1 front controller ActionServlet. Am I thinking correctly?
<servlet>
<servlet-name>module1</servlet-name>
<servlet-class>com.xyz.module1.BasicsServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>module1</servlet-name>
<url-pattern>Module1.xp</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>Module9.do</url-pattern>
</servlet-mapping>
PS: I believe if the above is possible,then we can use strut2 also
Solution
Yes it is possible. below is my web.xml,In My code MyServlet
is extending ActionServlet
and ImageFormationServlet
is extending HttpServlet
.
<web-app>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>com.core.system.MyServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>ImageFormationServlet</servlet-name>
<servlet-class>com.core.system.servlet.ImageFormationServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ImageFormationServlet</servlet-name>
<url-pattern>/servlet/ImageFormationServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow