public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException,
ServletException, CommunicationException, NamingException
{
String dataSource = Settings.getInstance().getSiteInfo(CVUtility.getHostName(super.getServlet().getServletContext())).getDataSource();
AdvancedSearchHome advancedSearchHome = (AdvancedSearchHome) CVUtility.getHomeObject("com.centraview.advancedsearch.AdvancedSearchHome",
"AdvancedSearch");
PrintTemplateHome PTHome = (PrintTemplateHome) CVUtility.getHomeObject("com.centraview.printtemplate.PrintTemplateHome", "Printtemplate");
MailHome mailHome = (MailHome) CVUtility.getHomeObject("com.centraview.mail.MailHome", "Mail");
try {
HttpSession session = request.getSession();
UserObject userObject = (UserObject) session.getAttribute("userobject");
int individualID = userObject.getIndividualID();
DynaActionForm dynaform = (DynaActionForm) form;
String mergeType = (String) dynaform.get("mergetype");
String actionType = null;
if (request.getParameter("actionType") != null) {
actionType = request.getParameter("actionType");
}
int categoryId = this.getCategoryIdFromType(mergeType);
PrintTemplate PTRemote = PTHome.create();
PTRemote.setDataSource(dataSource);
AdvancedSearch remoteAdvancedSearch = advancedSearchHome.create();
remoteAdvancedSearch.setDataSource(dataSource);
String savedsearch1 = "";
String specificentity = "";
String entitysavedsearch = "";
if (mergeType.equals("EMAIL")) {