{"id":205,"date":"2007-09-06T00:00:00","date_gmt":"2007-09-06T00:00:00","guid":{"rendered":"http:\/\/www.strongd.net\/?p=205"},"modified":"2007-09-06T00:00:00","modified_gmt":"2007-09-06T00:00:00","slug":"Developing Struts Web Module","status":"publish","type":"post","link":"https:\/\/www.strongd.net\/?p=205","title":{"rendered":"Developing Struts Web Module"},"content":{"rendered":"<p><P>In this we will be creating search interface for enabling the user to search tutorials. This example is an client to test our Struts Hibernate Plugin.<\/P><br \/>\n<P>The web component of the application consists of the following files:<\/P><br \/>\n<P><B>1. Search Tutorial Form (SearchTutorial.jsp):<\/B><\/P><br \/>\n<P>This file is used to display the search form to the user. Here is the code of search form:<\/P><br \/>\n<DIV align=left><br \/>\n<TABLE cellSpacing=0 cellPadding=0 width=\"75%\" bgColor=#ffff99 border=1><br \/>\n<TBODY><br \/>\n<TR><br \/>\n<TD width=\"100%\"><PRE>&lt;%@ taglib uri=&#8221;\/tags\/struts-bean&#8221; prefix=&#8221;bean&#8221; %&gt;<\/p>\n<p>   &lt;%@ taglib uri=&#8221;\/tags\/struts-html&#8221; prefix=&#8221;html&#8221; %&gt;<br \/>\n   &lt;html:html locale=&#8221;true&#8221;&gt;<br \/>\n   &lt;head&gt;<br \/>\n   &lt;title&gt;&lt;bean:message key=&#8221;welcome.title&#8221;\/&gt;&lt;\/title&gt;<br \/>\n   &lt;html:base\/&gt;<br \/>\n   &lt;\/head&gt;<br \/>\n   &lt;body bgcolor=&#8221;white&#8221;&gt;<\/p>\n<p>   &lt;html:form action=&#8221;\/searchTutorial&#8221;&gt;<\/p>\n<p>   &lt;html:errors\/&gt;<\/p>\n<p>   &lt;table&gt;<\/p>\n<p>     &lt;tr&gt;<br \/>\n          &lt;td align=&#8221;right&#8221;&gt;<br \/>\n            Search Tutorial<br \/>\n          &lt;\/td&gt;<br \/>\n          &lt;td align=&#8221;left&#8221;&gt;<br \/>\n            &lt;html:text property=&#8221;keyword&#8221; size=&#8221;30&#8243; maxlength=&#8221;30&#8243;\/&gt;<br \/>\n          &lt;\/td&gt;<br \/>\n        &lt;\/tr&gt;&nbsp;<br \/>\n\t\t&lt;tr&gt;<br \/>\n          &lt;td align=&#8221;right&#8221;&gt;<br \/>\n            &lt;html:submit&gt;Search&lt;\/html:submit&gt;<br \/>\n          &lt;\/td&gt;<br \/>\n\t\t  &lt;\/tr&gt;<br \/>\n\t\t  &lt;\/table&gt;<br \/>\n   &lt;\/html:form&gt;<br \/>\n   &lt;\/body&gt;<br \/>\n   &lt;\/html:html&gt; <\/PRE><\/TD><\/TR><\/TBODY><\/TABLE><\/DIV><br \/>\n<P>Save <B>SearchTutorial.jsp<\/B> in to &#8220;<B>C:\\Struts-Hibernate-Integration\\code\\pages<\/B>&#8221; directory.<\/P><br \/>\n<P><B>2. Search Result Page (SearchResultPage.jsp)<\/B><BR>This page is used to display the search result. Here is the code of search result page:<\/P><br \/>\n<DIV align=left><br \/>\n<TABLE cellSpacing=0 cellPadding=0 width=\"64%\" bgColor=#ffff99 border=1><br \/>\n<TBODY><br \/>\n<TR><br \/>\n<TD width=\"100%\"><PRE>       &nbsp;&lt;%@page language=&#8221;java&#8221; import=&#8221;java.util.*&#8221;%&gt;<br \/>\n\t&lt;%@ taglib uri=&#8221;\/tags\/struts-bean&#8221; prefix=&#8221;bean&#8221; %&gt;<br \/>\n        &lt;%@ taglib uri=&#8221;\/tags\/struts-html&#8221; prefix=&#8221;html&#8221; %&gt;<br \/>\n        &lt;p&gt;&lt;font size=&#8221;4&#8243; color=&#8221;#800000&#8243; face=&#8221;Arial&#8221;&gt;Search Results&lt;\/font&gt;&lt;\/p&gt;<\/p>\n<p>        &lt;%<br \/>\n        List searchresult = (List) request.getAttribute(&#8220;searchresult&#8221;);<br \/>\n        %&gt;<br \/>\n        &lt;%<br \/>\n        for (Iterator itr=searchresult.iterator(); itr.hasNext(); )<br \/>\n        {<br \/>\n  roseindia.net.dao.hibernate.Tutorial tutorial =<br \/>\n      (roseindia.net.dao.hibernate.Tutorial)itr.next();<br \/>\n        %&gt;<br \/>\n        &lt;p&gt;&lt;a href=&#8221;&lt;%=tutorial.getPageurl()%&gt;&#8221;&gt;<br \/>\n        &lt;font face=&#8221;Arial&#8221; size=&#8221;3&#8243;&gt;&lt;%=tutorial.getShortdesc()%&gt;&lt;\/font&gt;&lt;\/a&gt;&lt;br&gt;<br \/>\n        &lt;font face=&#8221;Arial&#8221; size=&#8221;2&#8243;&gt;&lt;%=tutorial.getLongdesc()%&gt;&lt;\/font&gt;&lt;\/p&gt;<\/p>\n<p>        &lt;%<br \/>\n        }<br \/>\n        %&gt;<br \/>\n        &lt;html:link page=&#8221;\/pages\/SearchTutorial.jsp&#8221;&gt;Back to Search Page&lt;\/html:link&gt;<\/p>\n<p>        <\/PRE><\/TD><\/TR><\/TBODY><\/TABLE><\/DIV><br \/>\n<P>Save <B>SearchResultPage.jsp<\/B> in to &#8220;<B>C:\\Struts-Hibernate-Integration\\code\\pages<\/B>&#8221; directory.<\/P><br \/>\n<P><B>3. Search Java Form (SearchTutorialActionForm.java)<\/B><BR>This is the Struts action form class. Here is the code of the Action Form:<\/P><br \/>\n<DIV class=java align=left><br \/>\n<TABLE cellSpacing=0 cellPadding=3 bgColor=#ffff99 border=1><br \/>\n<TBODY><br \/>\n<TR><!-- start source code --><br \/>\n<TD vAlign=top noWrap align=left><CODE><FONT color=#7f0055><B>package&nbsp;<\/B><\/FONT><FONT color=#000000>roseindia.web;<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#7f0055><B>import&nbsp;<\/B><\/FONT><FONT color=#000000>javax.servlet.http.HttpServletRequest;<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#7f0055><B>import&nbsp;<\/B><\/FONT><FONT color=#000000>org.apache.struts.action.*;<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#7f0055><B>public&nbsp;class&nbsp;<\/B><\/FONT><FONT color=#000000>SearchTutorialActionForm&nbsp;<\/FONT><FONT color=#7f0055><B>extends&nbsp;<\/B><\/FONT><FONT color=#000000>ActionForm<\/FONT><BR><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>private&nbsp;<\/B><\/FONT><FONT color=#000000>String&nbsp;keyword=<\/FONT><FONT color=#7f0055><B>null<\/B><\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#7f0055><B>public&nbsp;<\/B><\/FONT><FONT color=#7f0055><B>void&nbsp;<\/B><\/FONT><FONT color=#000000>setKeyword<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>String&nbsp;keyword<\/FONT><FONT color=#000000>){<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>this<\/B><\/FONT><FONT color=#000000>.keyword=keyword;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>public&nbsp;<\/B><\/FONT><FONT color=#000000>String&nbsp;getKeyword<\/FONT><FONT color=#000000>(){<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>return&nbsp;this<\/B><\/FONT><FONT color=#000000>.keyword;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>public&nbsp;<\/B><\/FONT><FONT color=#7f0055><B>void&nbsp;<\/B><\/FONT><FONT color=#000000>reset<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>ActionMapping&nbsp;mapping,&nbsp;HttpServletRequest&nbsp;request<\/FONT><FONT color=#000000>)&nbsp;{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>this<\/B><\/FONT><FONT color=#000000>.keyword=<\/FONT><FONT color=#7f0055><B>null<\/B><\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>public&nbsp;<\/B><\/FONT><FONT color=#000000>ActionErrors&nbsp;validate<\/FONT><FONT color=#000000>(&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>ActionMapping&nbsp;mapping,&nbsp;HttpServletRequest&nbsp;request&nbsp;<\/FONT><FONT color=#000000>)&nbsp;{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>ActionErrors&nbsp;errors&nbsp;=&nbsp;<\/FONT><FONT color=#7f0055><B>new&nbsp;<\/B><\/FONT><FONT color=#000000>ActionErrors<\/FONT><FONT color=#000000>()<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>if<\/B><\/FONT><FONT color=#000000>(&nbsp;<\/FONT><FONT color=#000000>getKeyword<\/FONT><FONT color=#000000>()&nbsp;<\/FONT><FONT color=#000000>==&nbsp;<\/FONT><FONT color=#7f0055><B>null&nbsp;<\/B><\/FONT><FONT color=#000000>||&nbsp;getKeyword<\/FONT><FONT color=#000000>()<\/FONT><FONT color=#000000>.length<\/FONT><FONT color=#000000>()&nbsp;<\/FONT><FONT color=#000000>&lt;&nbsp;<\/FONT><FONT color=#990000>1&nbsp;<\/FONT><FONT color=#000000>)&nbsp;{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>errors.add<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;keyword&#8221;<\/FONT><FONT color=#000000>,new&nbsp;ActionMessage<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;error.keyword.required&#8221;<\/FONT><FONT color=#000000>))<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>return&nbsp;<\/B><\/FONT><FONT color=#000000>errors;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#000000>}<\/FONT><\/CODE> <\/TD><!-- end source code --><\/TR><\/TBODY><\/TABLE><\/DIV><br \/>\n<P><B>&nbsp;4. Search Action Class (SearchTutorialAction.java)<\/B><\/P><br \/>\n<P>This is Struts Action Class of our application. Here is the code of the Action Class:<\/P><br \/>\n<DIV class=java align=left><br \/>\n<TABLE cellSpacing=0 cellPadding=3 bgColor=#ffff99 border=1><br \/>\n<TBODY><br \/>\n<TR><!-- start source code --><br \/>\n<TD vAlign=top noWrap align=left><CODE><FONT color=#7f0055><B>package&nbsp;<\/B><\/FONT><FONT color=#000000>roseindia.web;<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#7f0055><B>import&nbsp;<\/B><\/FONT><FONT color=#000000>javax.servlet.http.HttpServletRequest;<\/FONT><BR><FONT color=#7f0055><B>import&nbsp;<\/B><\/FONT><FONT color=#000000>javax.servlet.http.HttpServletResponse;<\/FONT><BR><FONT color=#7f0055><B>import&nbsp;<\/B><\/FONT><FONT color=#000000>javax.servlet.ServletContext;<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#7f0055><B>import&nbsp;<\/B><\/FONT><FONT color=#000000>java.util.List;<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#7f0055><B>import&nbsp;<\/B><\/FONT><FONT color=#000000>org.apache.struts.action.Action;<\/FONT><BR><FONT color=#7f0055><B>import&nbsp;<\/B><\/FONT><FONT color=#000000>org.apache.struts.action.ActionForm;<\/FONT><BR><FONT color=#7f0055><B>import&nbsp;<\/B><\/FONT><FONT color=#000000>org.apache.struts.action.ActionForward;<\/FONT><BR><FONT color=#7f0055><B>import&nbsp;<\/B><\/FONT><FONT color=#000000>org.apache.struts.action.ActionMapping;<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#7f0055><B>import&nbsp;<\/B><\/FONT><FONT color=#000000>roseindia.net.plugin.HibernatePlugIn;<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#7f0055><B>import&nbsp;<\/B><\/FONT><FONT color=#000000>roseindia.net.dao.hibernate.Tutorial;<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#7f0055><B>import&nbsp;<\/B><\/FONT><FONT color=#000000>org.hibernate.SessionFactory;<\/FONT><BR><FONT color=#7f0055><B>import&nbsp;<\/B><\/FONT><FONT color=#000000>org.hibernate.Session;<\/FONT><BR><FONT color=#7f0055><B>import&nbsp;<\/B><\/FONT><FONT color=#000000>org.hibernate.criterion.Restrictions;<\/FONT><BR><FONT color=#7f0055><B>import&nbsp;<\/B><\/FONT><FONT color=#000000>org.hibernate.Criteria;<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#7f0055><B>public&nbsp;class&nbsp;<\/B><\/FONT><FONT color=#000000>SearchTutorialAction&nbsp;<\/FONT><FONT color=#7f0055><B>extends&nbsp;<\/B><\/FONT><FONT color=#000000>Action<\/FONT><BR><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>public&nbsp;<\/B><\/FONT><FONT color=#000000>ActionForward&nbsp;execute<\/FONT><FONT color=#000000>(<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>ActionMapping&nbsp;mapping,<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>ActionForm&nbsp;form,<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>HttpServletRequest&nbsp;request,<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>HttpServletResponse&nbsp;response<\/FONT><FONT color=#000000>)&nbsp;<\/FONT><FONT color=#7f0055><B>throws&nbsp;<\/B><\/FONT><FONT color=#000000>Exception<\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#000000>SearchTutorialActionForm&nbsp;formObj&nbsp;=&nbsp;<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>SearchTutorialActionForm<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>form;<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>System.out.println<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;Getting&nbsp;session&nbsp;factory&#8221;<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#3f7f5f>\/*Get&nbsp;the&nbsp;servlet&nbsp;context&nbsp;*\/<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>ServletContext&nbsp;context&nbsp;=&nbsp;request.getSession<\/FONT><FONT color=#000000>()<\/FONT><FONT color=#000000>.getServletContext<\/FONT><FONT color=#000000>()<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#3f7f5f>\/*Retrieve&nbsp;Session&nbsp;Factory&nbsp;*\/<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>SessionFactory&nbsp;_factory&nbsp;=&nbsp;<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>SessionFactory<\/FONT><FONT color=#000000>)&nbsp;&nbsp;<BR>&nbsp;&nbsp; context.getAttribute<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>HibernatePlugIn.SESSION_FACTORY_KEY<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#3f7f5f>\/*Open&nbsp;Hibernate&nbsp;Session&nbsp;*\/<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>Session&nbsp;&nbsp;session&nbsp;=&nbsp;_factory.openSession<\/FONT><FONT color=#000000>()<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#3f7f5f>\/\/Criteria&nbsp;Query&nbsp;Example<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>Criteria&nbsp;crit&nbsp;=&nbsp;session.createCriteria<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>Tutorial.<\/FONT><FONT color=#7f0055><B>class<\/B><\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>crit.add<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>Restrictions.like<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;shortdesc&#8221;<\/FONT><FONT color=#000000>,&nbsp;<\/FONT><FONT color=#2a00ff>&#8220;%&#8221;&nbsp;<\/FONT><FONT color=#000000>+&nbsp;formObj.getKeyword<\/FONT><FONT color=#000000>()&nbsp;<\/FONT><FONT color=#000000>+<\/FONT><FONT color=#2a00ff>&#8220;%&#8221;<\/FONT><FONT color=#000000>))<\/FONT><FONT color=#000000>;&nbsp;<\/FONT><FONT color=#3f7f5f>\/\/Like&nbsp;condition<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#3f7f5f>\/\/Fetch&nbsp;the&nbsp;result&nbsp;from&nbsp;database<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>List&nbsp;tutorials=&nbsp;crit.list<\/FONT><FONT color=#000000>()<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>request.setAttribute<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;searchresult&#8221;<\/FONT><FONT color=#000000>,tutorials<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#3f7f5f>\/*Close&nbsp;session&nbsp;*\/<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>session.close<\/FONT><FONT color=#000000>()<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>System.out.println<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;Hibernate&nbsp;Session&nbsp;Closed&#8221;<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>return&nbsp;<\/B><\/FONT><FONT color=#000000>mapping.findForward<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;success&#8221;<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#000000>}<\/FONT><\/CODE> <\/TD><!-- end source code --><\/TR><\/TBODY><\/TABLE><\/DIV><br \/>\n<P><B>5. Entries into struts-config.xml<\/B><\/P><br \/>\n<P>Add the following lines into your struts-config.xml file.<\/P><br \/>\n<P><B>Form Bean:&nbsp;<\/B><BR><FONT color=#0000ff>&lt;form-bean<BR>name=&#8221;TutorialSearch&#8221;<BR>type=&#8221;roseindia.web.SearchTutorialActionForm&#8221;&gt;<BR>&lt;\/form-bean&gt;<\/FONT><\/P><br \/>\n<P><B>Action Entry:<\/B><BR><FONT color=#0000ff>&lt;action<BR>path=&#8221;\/searchTutorial&#8221;<BR>type=&#8221;roseindia.web.SearchTutorialAction&#8221;<BR>name=&#8221;TutorialSearch&#8221;<BR>scope=&#8221;request&#8221;<BR>validate=&#8221;true&#8221;<BR>input=&#8221;\/pages\/SearchTutorial.jsp&#8221;&gt;<BR>&lt;forward name=&#8221;success&#8221; path=&#8221;\/pages\/SearchResultPage.jsp&#8221;\/&gt;<BR>&lt;\/action&gt;<\/FONT><\/P><br \/>\n<P>Now we have created all the required stuffs for the web client. In the next section we will test our application.<\/P><br \/>\n<DIV><\/DIV><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this we will be creating search interface for enabling the user to search tutorials. This example is an client to test our Struts Hibernate Plugin. The web component of the application consists of the following files: 1. Search Tutorial Form (SearchTutorial.jsp): This file is used to display the search form to the user. Here &hellip; <a href=\"https:\/\/www.strongd.net\/?p=205\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Developing Struts Web Module<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-205","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/205","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=205"}],"version-history":[{"count":0,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/205\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=205"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=205"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=205"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}