By: Fazal Emailed: 1729 times Printed: 2331 times
<jsp:include page="/xoom/LegacyServletA" />
It is very clear from the value of the page attribute that it is a non-Struts resource. Wouldn't it be better to have a <jsp:include> that pretends as if the resource exists in the current Struts application? It would be ideal if the page include looked as follows:
<jsp:include page="/App1/legacyA.do" />
The /legacyA.do cannot be a ForwardAction because it would perform a HTTP Forward to the above resource instead of including the resource in the HTTP response. Since the HTTP Response OutputStream closes (The J2EE jargon for this is the response has been committed) after HTTP Forward, the servlet container cannot process the rest of the JSP and include its response in the OutputStream. Consequently it throws a IllegalStateException with a message that “Response is already committed". IncludeAction addresses this problem. Instead of forwarding to the specified resource, it includes the resource in the current response. Consequently the output of the LegacyServletA is displayed in the same HTML as that of the Struts application. You have to add the following ActionMapping in the Struts Config file:
The parameter attribute indicates the actual resource that has to be included in the response. As mentioned earlier, the use of IncludeAction is limited to including responses from existing Servlet in the current page. This requires the use of <jsp:include> in the page. If you web application is aggregating response from legacy servlet applications, portlets seems to be the way to go. Portlet API - JSR 168 has been finalized and it is matter of time before you can develop standardized portals aggregating contents from disparate web applications. Tiles framework is the way to go if you are on a short-term project that wants to aggregate information now (From different applications or may be from various Actions in the same Struts application). Tiles provides a robust alternative to the primitive <jsp:include>.
This is an excerpt from the book "Struts Survival Guide". You can get more details from that book.
View Tutorial By: VIshwanath at 2011-03-21 06:00:22
Most Viewed Articles (in Struts )
Most Emailed Articles (in Struts)