These notes illustrate an interesting way of developing and using capture tags in jsp to accomodate masterpages or tiles. This specific example talks about how this is done in AspireWeb but the ideas can be easily extended to any java based server side framework.

The notes will explore a) how to define a jsp page in response to an incoming url in an MVC fashion b) it then goes into identifying a tiles or masterpage pertaining to that URL c) an example of the master page d) an example of the jsp page with capture tags e) the resulting out put combining the master page and the url specific jsp page. f) what the incoming url will look like


captestJSPURL=/testdir/capture/capture-test1.jsp
captestJSPURL.transformType=JSP
request.captestJSPURL.transform.className=com.ai.jsp.JSPTransform
captestJSPURL.dataRequestName=mydata

request.mydata.className=com.ai.htmlgen.DBHashTableFormHandler1

#############################################
# Your master jsp page
#############################################
captestURL=aspire:\\testdir\\capture\\captest.html

<html>
  <head>
    <title>A custom tag: body content</title>
  </head>
<body>
<hr>
{{cap1}}
<hr>
<p>After
</body>
</html>

<%@ taglib uri="/aic" prefix="aic" %>

<%@ page import="com.ai.htmlgen.*" %>
<%@ page import="com.ai.application.utils.*" %>
<%@ page import="com.ai.common.*" %>
<%@ page import="com.ai.aspire.utils.*" %>

<%!
String hello()
{
	return "helloworld. in deed";
}
%>

<%
	ihds pageData = (ihds)request.getAttribute("Aspire.formHandler");
	if (pageData == null)
	{
	   out.println("Some html segment about empty data set if needed");
	   return;      
	}    
%>	

<aic:CaptureTag captureAsName="cap1">
  	<p>Hello world</p>
  	<p>
  	<%="My name is super"%> <%=hello()%>
  	</p>
</aic:CaptureTag>

<!--
***********************************************
* End game. Going for a master page.
***********************************************
-->
<%
String cap1Value = (String)request.getAttribute("cap1");
java.util.HashMap map = new java.util.HashMap();
map.put("cap1",cap1Value);
java.io.PrintWriter myout = new java.io.PrintWriter(out);
TransformUtils.transformHds("captestUrl",myout,(IFormHandler)pageData,map);
%>

<!--
***********************************************
* End game. Going for a master page.
***********************************************
-->
<html>
  <head>
    <title>A custom tag: body content</title>
  </head>
<body>
<hr>

  	<p>Hello world</p>
  	<p>
  	My name is super helloworld. in deed
  	</p>

<hr>
<p>After
<hr>

</body>
</html>

http://localhost:8181/akc/display?url=captestJSPURL

###################################
# ShowFiledReportsViewIMPJSPURL
###################################
ShowFiledReportsViewIMPJSPURL=/reports/report-filing/reports-summary-view-imp.jsp
ShowFiledReportsViewIMPJSPURL.transformType=JSP
request.ShowFiledReportsViewIMPJSPURL.transform.className=com.ai.jsp.MPJSPIncludeTransform
ShowFiledReportsViewIMPJSPURL.dataRequestName=ShowFiledReportsViewURLFormHandler
ShowFiledReportsViewIMPJSPURL.masterPageRequestName=GetMasterPage
ShowFiledReportsViewIMPJSPURL.masterPageURL=captestURL2