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 is the code of search form:
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<html:html locale="true">
<head>
<title><bean:message key="welcome.title"/></title>
<html:base/>
</head>
<body bgcolor="white">
<html:form action="/searchTutorial">
<html:errors/>
<table>
<tr>
<td align="right">
Search Tutorial
</td>
<td align="left">
<html:text property= |
Save SearchTutorial.jsp in to "C:\Struts-Hibernate-Integration\code\pages" directory.
2. Search Result Page (SearchResultPage.jsp)
This page is used to display the search result. Here is the code of search
result page:
<%@page language="java" import="java.util.*"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<p><font size="4" color=
|
Save SearchResultPage.jsp in to "C:\Struts-Hibernate-Integration\code\pages" directory.
3. Search Java Form (SearchTutorialActionForm.java)
This is the Struts action form class. Here is the code of the Action Form:
package roseindia.web;
|
4. Search Action Class (SearchTutorialAction.java)
This is Struts Action Class of our application. Here is the code of the Action Class:
package roseindia.web;
|
5. Entries into struts-config.xml
Add the following lines into your struts-config.xml file.
Form Bean:
<form-bean
name="TutorialSearch"
type="roseindia.web.SearchTutorialActionForm">
</form-bean>
Action Entry:
<action
path="/searchTutorial"
type="roseindia.web.SearchTutorialAction"
name="TutorialSearch"
scope="request"
validate="true"
input="/pages/SearchTutorial.jsp">
<forward name="success" path="/pages/SearchResultPage.jsp"/>
</action>
Now we have created all the required stuffs for the web client. In the next section we will test our application.
|
Recommend the tutorial |

Ask Questions? Discuss: Developing Struts Web Module View All Comments
Post your Comment