<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JSP, Tomcat, JDBC, Projects, Example, Program &#187; Struts</title>
	<atom:link href="http://www.easywayserver.com/blog/category/struts/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.easywayserver.com/blog</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sat, 04 Jun 2011 05:32:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Building a User Registration Application</title>
		<link>http://www.easywayserver.com/blog/building-a-user-registration-application/</link>
		<comments>http://www.easywayserver.com/blog/building-a-user-registration-application/#comments</comments>
		<pubDate>Sun, 05 Dec 2010 08:11:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JSP]]></category>
		<category><![CDATA[Struts]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[struts examples]]></category>

		<guid isPermaLink="false">http://www.easywayserver.com/blog/?p=598</guid>
		<description><![CDATA[User Registration is basic need of any web application. This tutorial will give you a rough idea to create user sign in application.  This user registration application can be easily integrated with any existing old application. User Registration is developed on Struts framework and follow MVC pattern. Application is containing three packages actions, model [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.easywayserver.com%2Fblog%2Fbuilding-a-user-registration-application%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.easywayserver.com%2Fblog%2Fbuilding-a-user-registration-application%2F" height="61" width="51" /></a></div><p>User Registration is basic need of any web application. This tutorial will give you a rough idea to create user sign in application.  This user registration application can be easily integrated with any existing old application. User Registration is developed on Struts framework and follow MVC pattern. Application is containing three packages actions, model and util. actions package contains all those class which are action class of struts and formbean actionform classes. Model package contain all those classes which are used for logical part and business part. Util package contain only those classes to give helping to application, e.g. Database connection classes, closing object classes and properties file.
</p>
<p>
<h3>Steps to Create  user Registration  application</h3>
</p>
<p><strong>UserRegisterForm.java</strong></p>
<div class="cde" style="overflow: auto; width: 570px;">
<pre><span style='color:#800000; font-weight:bold; '>package</span><span style='color:#004a43; '> com</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>register</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>actions</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> org</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>apache</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>struts</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>validator</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>ValidatorForm</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>class</span> UserRegisterForm <span style='color:#800000; font-weight:bold; '>extends</span> ValidatorForm<span style='color:#800080; '>{</span>

    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#800000; font-weight:bold; '>static</span> <span style='color:#800000; font-weight:bold; '>final</span> <span style='color:#bb7977; '>long</span> serialVersionUID <span style='color:#808030; '>=</span> <span style='color:#008c00; '>1</span><span style='color:#006600; '>L</span><span style='color:#800080; '>;</span>

    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> emailid<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> password<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> cpassword<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> firstname<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> lastname<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> gender<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> submitError<span style='color:#800080; '>;</span>

    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getSubmitError<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> submitError<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setSubmitError<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> submitError<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>submitError <span style='color:#808030; '>=</span> submitError<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getPassword<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> password<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setPassword<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> password<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>password <span style='color:#808030; '>=</span> password<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getEmailid<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> emailid<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setEmailid<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> emailid<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>emailid <span style='color:#808030; '>=</span> emailid<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getCpassword<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> cpassword<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setCpassword<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> cpassword<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>cpassword <span style='color:#808030; '>=</span> cpassword<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getFirstname<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> firstname<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setFirstname<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> firstname<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>firstname <span style='color:#808030; '>=</span> firstname<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getLastname<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> lastname<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setLastname<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> lastname<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>lastname <span style='color:#808030; '>=</span> lastname<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getGender<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> gender<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setGender<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> gender<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>gender <span style='color:#808030; '>=</span> gender<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
<span style='color:#800080; '>}</span>
</pre>
</div>
<p><strong>UserRegistrationAction.java</strong></p>
<div class="cde"  style="overflow: auto; width: 570px;">
<pre><span style='color:#800000; font-weight:bold; '>package</span><span style='color:#004a43; '> com</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>register</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>actions</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> javax</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>servlet</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>http</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>HttpServletRequest</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> javax</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>servlet</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>http</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>HttpServletResponse</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> org</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>apache</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>struts</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>action</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>Action</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> org</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>apache</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>struts</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>action</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>ActionForm</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> org</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>apache</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>struts</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>action</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>ActionForward</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> org</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>apache</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>struts</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>action</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>ActionMapping</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> org</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>apache</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>struts</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>action</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>ActionMessage</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> org</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>apache</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>struts</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>action</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>ActionMessages</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> com</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>register</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>model</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>UserRegistration</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>class</span> UserRegistrationAction <span style='color:#800000; font-weight:bold; '>extends</span> Action <span style='color:#800080; '>{</span>

    <span style='color:#800000; font-weight:bold; '>public</span> ActionForward execute<span style='color:#808030; '>(</span>ActionMapping mapping<span style='color:#808030; '>,</span> ActionForm form<span style='color:#808030; '>,</span>
            HttpServletRequest request<span style='color:#808030; '>,</span> HttpServletResponse response<span style='color:#808030; '>)</span>
            <span style='color:#800000; font-weight:bold; '>throws</span> <span style='color:#bb7977; font-weight:bold; '>Exception</span> <span style='color:#800080; '>{</span>

        <span style='color:#bb7977; '>boolean</span> action_perform <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>false</span><span style='color:#800080; '>;</span>
        <span style='color:#bb7977; font-weight:bold; '>String</span> action_target<span style='color:#800080; '>;</span>

        UserRegistration u <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> UserRegistration<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        ActionMessages errors_mesg <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> ActionMessages<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        UserRegisterForm uf <span style='color:#808030; '>=</span> <span style='color:#808030; '>(</span>UserRegisterForm<span style='color:#808030; '>)</span> form<span style='color:#800080; '>;</span>

        <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>form <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
            u<span style='color:#808030; '>.</span>setEmail<span style='color:#808030; '>(</span>uf<span style='color:#808030; '>.</span>getEmailid<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            u<span style='color:#808030; '>.</span>setPassword<span style='color:#808030; '>(</span>uf<span style='color:#808030; '>.</span>getPassword<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            u<span style='color:#808030; '>.</span>setFirstName<span style='color:#808030; '>(</span>uf<span style='color:#808030; '>.</span>getFirstname<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            u<span style='color:#808030; '>.</span>setLastName<span style='color:#808030; '>(</span>uf<span style='color:#808030; '>.</span>getLastname<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            u<span style='color:#808030; '>.</span>setGender<span style='color:#808030; '>(</span>uf<span style='color:#808030; '>.</span>getGender<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            action_perform <span style='color:#808030; '>=</span> u<span style='color:#808030; '>.</span>newuserregistration<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

            <span style='color:#bb7977; font-weight:bold; '>String</span> sError<span style='color:#808030; '>=</span>u<span style='color:#808030; '>.</span>getDbError<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            <span style='color:#800000; font-weight:bold; '>if</span><span style='color:#808030; '>(</span>sError<span style='color:#808030; '>.</span>equalsIgnoreCase<span style='color:#808030; '>(</span><span style='color:#0000e6; '>&quot;error&quot;</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span>
            <span style='color:#800080; '>{</span>
                errors_mesg<span style='color:#808030; '>.</span>add<span style='color:#808030; '>(</span><span style='color:#0000e6; '>&quot;submitError&quot;</span><span style='color:#808030; '>,</span>
                    <span style='color:#800000; font-weight:bold; '>new</span> ActionMessage<span style='color:#808030; '>(</span><span style='color:#0000e6; '>&quot;errors.user.registration.email.duplicate&quot;</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
                saveErrors<span style='color:#808030; '>(</span>request<span style='color:#808030; '>,</span>errors_mesg<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            <span style='color:#800080; '>}</span>
        <span style='color:#800080; '>}</span>

        <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>action_perform <span style='color:#808030; '>=</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>false</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
            errors_mesg<span style='color:#808030; '>.</span>add<span style='color:#808030; '>(</span><span style='color:#0000e6; '>&quot;submitError&quot;</span><span style='color:#808030; '>,</span>
                    <span style='color:#800000; font-weight:bold; '>new</span> ActionMessage<span style='color:#808030; '>(</span><span style='color:#0000e6; '>&quot;errors.user.registration.fail&quot;</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            saveErrors<span style='color:#808030; '>(</span>request<span style='color:#808030; '>,</span> errors_mesg<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            action_target <span style='color:#808030; '>=</span> <span style='color:#0000e6; '>&quot;failure&quot;</span><span style='color:#800080; '>;</span>
        <span style='color:#800080; '>}</span> <span style='color:#800000; font-weight:bold; '>else</span> <span style='color:#800080; '>{</span>
            errors_mesg<span style='color:#808030; '>.</span>add<span style='color:#808030; '>(</span><span style='color:#0000e6; '>&quot;submitError&quot;</span><span style='color:#808030; '>,</span>
                    <span style='color:#800000; font-weight:bold; '>new</span> ActionMessage<span style='color:#808030; '>(</span><span style='color:#0000e6; '>&quot;errors.user.registration.success&quot;</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            saveErrors<span style='color:#808030; '>(</span>request<span style='color:#808030; '>,</span> errors_mesg<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            action_target <span style='color:#808030; '>=</span> <span style='color:#0000e6; '>&quot;success&quot;</span><span style='color:#800080; '>;</span>
        <span style='color:#800080; '>}</span>

        <span style='color:#800000; font-weight:bold; '>return</span> mapping<span style='color:#808030; '>.</span>findForward<span style='color:#808030; '>(</span>action_target<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
<span style='color:#800080; '>}</span>
</pre>
</div>
<p>User.java</p>
<div class="cde"  style="overflow: auto; width: 570px;">
<pre><span style='color:#800000; font-weight:bold; '>package</span><span style='color:#004a43; '> com</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>register</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>model</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> java</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>io</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>Serializable</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> java</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>util</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>Date</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>class</span> User <span style='color:#800000; font-weight:bold; '>implements</span> Serializable<span style='color:#800080; '>{</span>

    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#800000; font-weight:bold; '>static</span> <span style='color:#800000; font-weight:bold; '>final</span> <span style='color:#bb7977; '>long</span> serialVersionUID <span style='color:#808030; '>=</span> <span style='color:#008c00; '>1</span><span style='color:#006600; '>L</span><span style='color:#800080; '>;</span>

    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; '>int</span> id<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; '>int</span> level<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> password<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> cpassword<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> forgetpassword<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>Date</span> lastVisit<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>Date</span> registrationDate<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> email<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> webSite<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> occupation<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> gender<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> timeZone<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> dateFormat<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; '>int</span> active<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> activationKey<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; '>int</span> deleted<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> firstName<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> lastName<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> ipAddress<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> macAddress<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; '>int</span> failLoginAttempted<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> dbError<span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;&quot;</span><span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getActivationKey<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> activationKey<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setActivationKey<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> activationKey<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>activationKey <span style='color:#808030; '>=</span> activationKey<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>int</span> getActive<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> active<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setActive<span style='color:#808030; '>(</span><span style='color:#bb7977; '>int</span> active<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>active <span style='color:#808030; '>=</span> active<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getDateFormat<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> dateFormat<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setDateFormat<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> dateFormat<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>dateFormat <span style='color:#808030; '>=</span> dateFormat<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>int</span> getDeleted<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> deleted<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setDeleted<span style='color:#808030; '>(</span><span style='color:#bb7977; '>int</span> deleted<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>deleted <span style='color:#808030; '>=</span> deleted<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getEmail<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> email<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setEmail<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> email<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>email <span style='color:#808030; '>=</span> email<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>int</span> getFailLoginAttempted<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> failLoginAttempted<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setFailLoginAttempted<span style='color:#808030; '>(</span><span style='color:#bb7977; '>int</span> failLoginAttempted<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>failLoginAttempted <span style='color:#808030; '>=</span> failLoginAttempted<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getFirstName<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> firstName<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setFirstName<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> firstName<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>firstName <span style='color:#808030; '>=</span> firstName<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getGender<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> gender<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setGender<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> gender<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>gender <span style='color:#808030; '>=</span> gender<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>int</span> getId<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> id<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setId<span style='color:#808030; '>(</span><span style='color:#bb7977; '>int</span> id<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>id <span style='color:#808030; '>=</span> id<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getIpAddress<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> ipAddress<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setIpAddress<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> ipAddress<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>ipAddress <span style='color:#808030; '>=</span> ipAddress<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getLastName<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> lastName<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setLastName<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> lastName<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>lastName <span style='color:#808030; '>=</span> lastName<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>Date</span> getLastVisit<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> lastVisit<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setLastVisit<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>Date</span> lastVisit<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>lastVisit <span style='color:#808030; '>=</span> lastVisit<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>int</span> getLevel<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> level<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setLevel<span style='color:#808030; '>(</span><span style='color:#bb7977; '>int</span> level<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>level <span style='color:#808030; '>=</span> level<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getMacAddress<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> macAddress<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setMacAddress<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> macAddress<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>macAddress <span style='color:#808030; '>=</span> macAddress<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getOccupation<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> occupation<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setOccupation<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> occupation<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>occupation <span style='color:#808030; '>=</span> occupation<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getPassword<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> password<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setPassword<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> password<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>password <span style='color:#808030; '>=</span> password<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>Date</span> getRegistrationDate<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> registrationDate<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setRegistrationDate<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>Date</span> registrationDate<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>registrationDate <span style='color:#808030; '>=</span> registrationDate<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getTimeZone<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> timeZone<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setTimeZone<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> timeZone<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>timeZone <span style='color:#808030; '>=</span> timeZone<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getWebSite<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> webSite<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setWebSite<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> webSite<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>webSite <span style='color:#808030; '>=</span> webSite<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getForgetpassword<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> forgetpassword<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setForgetpassword<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> forgetpassword<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>forgetpassword <span style='color:#808030; '>=</span> forgetpassword<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getCpassword<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> cpassword<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setCpassword<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> cpassword<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>cpassword <span style='color:#808030; '>=</span> cpassword<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getDbError<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> dbError<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setDbError<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> dbError<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>dbError <span style='color:#808030; '>=</span> dbError<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>

<span style='color:#800080; '>}</span>
</pre>
</div>
<p><strong>UserRegistration.java</strong></p>
<div class="cde"  style="overflow: auto; width: 570px;">
<pre><span style='color:#800000; font-weight:bold; '>package</span><span style='color:#004a43; '> com</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>register</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>model</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> java</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>sql</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>Connection</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> java</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>sql</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>PreparedStatement</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> com</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>register</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>util</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>ConnectionUtils</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> com</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>register</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>util</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>DbUtils</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>class</span> UserRegistration <span style='color:#800000; font-weight:bold; '>extends</span> User<span style='color:#800080; '>{</span>

    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#800000; font-weight:bold; '>static</span> <span style='color:#800000; font-weight:bold; '>final</span> <span style='color:#bb7977; '>long</span> serialVersionUID <span style='color:#808030; '>=</span> <span style='color:#008c00; '>1</span><span style='color:#006600; '>L</span><span style='color:#800080; '>;</span>

    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>boolean</span> newuserregistration<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800000; font-weight:bold; '>throws</span> <span style='color:#bb7977; font-weight:bold; '>Exception</span>
    <span style='color:#800080; '>{</span>
        <span style='color:#bb7977; font-weight:bold; '>PreparedStatement</span> psUserRegistration <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#800080; '>;</span>
        <span style='color:#bb7977; font-weight:bold; '>String</span> sqlUserRegistration <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#800080; '>;</span>

        <span style='color:#bb7977; '>boolean</span> isRegistered <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>false</span><span style='color:#800080; '>;</span>

        <span style='color:#bb7977; font-weight:bold; '>Connection</span> conn <span style='color:#808030; '>=</span> ConnectionUtils<span style='color:#808030; '>.</span>getConnection<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        sqlUserRegistration <span style='color:#808030; '>=</span> <span style='color:#0000e6; '>&quot;insert into user_master(sEmail, sPassword, sFirstName,&quot;</span> <span style='color:#808030; '>+</span>
                              <span style='color:#0000e6; '>&quot; sLastName, cGender, iUserType, sCreatedDate, cStatus)&quot;</span> <span style='color:#808030; '>+</span>
                              <span style='color:#0000e6; '>&quot; values(?,md5(?),?,?,?,1,sysdate(),'A')&quot;</span><span style='color:#800080; '>;</span>

        <span style='color:#800000; font-weight:bold; '>try</span><span style='color:#800080; '>{</span>
            psUserRegistration <span style='color:#808030; '>=</span> conn<span style='color:#808030; '>.</span>prepareStatement<span style='color:#808030; '>(</span>sqlUserRegistration<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            psUserRegistration<span style='color:#808030; '>.</span>setString<span style='color:#808030; '>(</span><span style='color:#008c00; '>1</span><span style='color:#808030; '>,</span> <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>getEmail<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            psUserRegistration<span style='color:#808030; '>.</span>setString<span style='color:#808030; '>(</span><span style='color:#008c00; '>2</span><span style='color:#808030; '>,</span> <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>getPassword<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            psUserRegistration<span style='color:#808030; '>.</span>setString<span style='color:#808030; '>(</span><span style='color:#008c00; '>3</span><span style='color:#808030; '>,</span> <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>getFirstName<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            psUserRegistration<span style='color:#808030; '>.</span>setString<span style='color:#808030; '>(</span><span style='color:#008c00; '>4</span><span style='color:#808030; '>,</span> <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>getLastName<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            psUserRegistration<span style='color:#808030; '>.</span>setString<span style='color:#808030; '>(</span><span style='color:#008c00; '>5</span><span style='color:#808030; '>,</span> <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>getGender<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            psUserRegistration<span style='color:#808030; '>.</span>executeUpdate<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

            isRegistered<span style='color:#808030; '>=</span><span style='color:#800000; font-weight:bold; '>true</span><span style='color:#800080; '>;</span>
        <span style='color:#800080; '>}</span>
        <span style='color:#800000; font-weight:bold; '>catch</span><span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>Exception</span> e<span style='color:#808030; '>)</span>
        <span style='color:#800080; '>{</span>
            <span style='color:#bb7977; font-weight:bold; '>String</span> errorMessage<span style='color:#808030; '>=</span>e<span style='color:#808030; '>.</span>getMessage<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            e<span style='color:#808030; '>.</span>printStackTrace<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            <span style='color:#800000; font-weight:bold; '>if</span><span style='color:#808030; '>(</span>errorMessage<span style='color:#808030; '>.</span>indexOf<span style='color:#808030; '>(</span><span style='color:#0000e6; '>&quot;Duplicate entry&quot;</span><span style='color:#808030; '>)</span><span style='color:#808030; '>></span><span style='color:#808030; '>=</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>)</span>
            <span style='color:#800080; '>{</span>
                <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>setDbError<span style='color:#808030; '>(</span><span style='color:#0000e6; '>&quot;error&quot;</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            <span style='color:#800080; '>}</span>
            isRegistered<span style='color:#808030; '>=</span><span style='color:#800000; font-weight:bold; '>false</span><span style='color:#800080; '>;</span>
            e<span style='color:#808030; '>.</span>printStackTrace<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#800080; '>}</span>
        DbUtils<span style='color:#808030; '>.</span>close<span style='color:#808030; '>(</span>psUserRegistration<span style='color:#808030; '>,</span> conn<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        <span style='color:#800000; font-weight:bold; '>return</span> isRegistered<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
<span style='color:#800080; '>}</span>
</pre>
</div>
<p>ConnectionUtils.java</p>
<div class="cde"  style="overflow: auto; width: 570px;">
<pre><span style='color:#800000; font-weight:bold; '>package</span><span style='color:#004a43; '> com</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>register</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>util</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> java</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>sql</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>Connection</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> java</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>sql</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>DriverManager</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> org</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>apache</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>struts</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>util</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>MessageResources</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>class</span> ConnectionUtils <span style='color:#800080; '>{</span>

    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#800000; font-weight:bold; '>static</span> MessageResources messages
     <span style='color:#808030; '>=</span> MessageResources<span style='color:#808030; '>.</span>getMessageResources<span style='color:#808030; '>(</span><span style='color:#0000e6; '>&quot;com.register.util.ApplicationResources&quot;</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#800000; font-weight:bold; '>static</span> <span style='color:#bb7977; font-weight:bold; '>String</span> USER_NAME_DB<span style='color:#808030; '>=</span>messages<span style='color:#808030; '>.</span>getMessage<span style='color:#808030; '>(</span><span style='color:#0000e6; '>&quot;db.user&quot;</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#800000; font-weight:bold; '>static</span> <span style='color:#bb7977; font-weight:bold; '>String</span> USER_PASSWORD_DB<span style='color:#808030; '>=</span>messages<span style='color:#808030; '>.</span>getMessage<span style='color:#808030; '>(</span><span style='color:#0000e6; '>&quot;db.password&quot;</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#800000; font-weight:bold; '>static</span> <span style='color:#bb7977; font-weight:bold; '>String</span> DB_NAME<span style='color:#808030; '>=</span>messages<span style='color:#808030; '>.</span>getMessage<span style='color:#808030; '>(</span><span style='color:#0000e6; '>&quot;db.dbname&quot;</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#800000; font-weight:bold; '>static</span> <span style='color:#bb7977; font-weight:bold; '>String</span> HOST_NAME<span style='color:#808030; '>=</span>messages<span style='color:#808030; '>.</span>getMessage<span style='color:#808030; '>(</span><span style='color:#0000e6; '>&quot;db.host&quot;</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

    <span style='color:#800000; font-weight:bold; '>static</span><span style='color:#800080; '>{</span>
          <span style='color:#800000; font-weight:bold; '>try</span> <span style='color:#800080; '>{</span>
                 <span style='color:#bb7977; font-weight:bold; '>Class</span><span style='color:#808030; '>.</span>forName<span style='color:#808030; '>(</span><span style='color:#0000e6; '>&quot;com.mysql.jdbc.Driver&quot;</span><span style='color:#808030; '>)</span><span style='color:#808030; '>.</span>newInstance<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
          <span style='color:#800080; '>}</span> <span style='color:#800000; font-weight:bold; '>catch</span> <span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>Exception</span> ex<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
          <span style='color:#800080; '>}</span>
    <span style='color:#800080; '>}</span>

    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>static</span> <span style='color:#bb7977; font-weight:bold; '>Connection</span> getConnection<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800000; font-weight:bold; '>throws</span> <span style='color:#bb7977; font-weight:bold; '>Exception</span>
    <span style='color:#800080; '>{</span>
           <span style='color:#800000; font-weight:bold; '>return</span> getDBConnection<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>

     <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>static</span> <span style='color:#bb7977; font-weight:bold; '>Connection</span> getDBConnection<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800000; font-weight:bold; '>throws</span> <span style='color:#bb7977; font-weight:bold; '>Exception</span>
      <span style='color:#800080; '>{</span>
          <span style='color:#bb7977; font-weight:bold; '>Connection</span> conn <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#800080; '>;</span>
          <span style='color:#bb7977; font-weight:bold; '>String</span> <span style='color:#bb7977; font-weight:bold; '>URL</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;jdbc:mysql://&quot;</span><span style='color:#808030; '>+</span>HOST_NAME<span style='color:#808030; '>+</span><span style='color:#0000e6; '>&quot;:3306/&quot;</span><span style='color:#808030; '>+</span>DB_NAME<span style='color:#800080; '>;</span>
          <span style='color:#800000; font-weight:bold; '>try</span><span style='color:#800080; '>{</span>
              conn <span style='color:#808030; '>=</span> <span style='color:#bb7977; font-weight:bold; '>DriverManager</span><span style='color:#808030; '>.</span>getConnection<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>URL</span><span style='color:#808030; '>,</span>USER_NAME_DB<span style='color:#808030; '>,</span> USER_PASSWORD_DB<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
          <span style='color:#800080; '>}</span>
          <span style='color:#800000; font-weight:bold; '>catch</span><span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>Exception</span> e<span style='color:#808030; '>)</span>
          <span style='color:#800080; '>{</span>
              e<span style='color:#808030; '>.</span>printStackTrace<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
          <span style='color:#800080; '>}</span>

          <span style='color:#800000; font-weight:bold; '>return</span> conn<span style='color:#800080; '>;</span>
      <span style='color:#800080; '>}</span>
<span style='color:#800080; '>}</span>
</pre>
</div>
<p><strong>DbUtils.java</strong></p>
<div class="cde"  style="overflow: auto; width: 570px;">
<pre><span style='color:#800000; font-weight:bold; '>package</span><span style='color:#004a43; '> com</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>register</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>util</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> java</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>sql</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>Connection</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> java</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>sql</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>PreparedStatement</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> java</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>sql</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>ResultSet</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> java</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>sql</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>SQLException</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> java</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>sql</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>Statement</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>class</span> DbUtils <span style='color:#800080; '>{</span>

    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>static</span> <span style='color:#bb7977; '>void</span> close<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>ResultSet</span> rs<span style='color:#808030; '>,</span> <span style='color:#bb7977; font-weight:bold; '>Statement</span> stm<span style='color:#808030; '>)</span>
    <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>rs <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
            <span style='color:#800000; font-weight:bold; '>try</span> <span style='color:#800080; '>{</span>
                rs<span style='color:#808030; '>.</span>close<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            <span style='color:#800080; '>}</span>
            <span style='color:#800000; font-weight:bold; '>catch</span> <span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>Exception</span> e<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span> <span style='color:#800080; '>}</span>
        <span style='color:#800080; '>}</span>

        <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>stm <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
            <span style='color:#800000; font-weight:bold; '>try</span> <span style='color:#800080; '>{</span>
                stm<span style='color:#808030; '>.</span>close<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            <span style='color:#800080; '>}</span>
            <span style='color:#800000; font-weight:bold; '>catch</span> <span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>Exception</span> e<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span> <span style='color:#800080; '>}</span>
        <span style='color:#800080; '>}</span>
    <span style='color:#800080; '>}</span>

    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>static</span> <span style='color:#bb7977; '>void</span> close<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>ResultSet</span> rs<span style='color:#808030; '>,</span> <span style='color:#bb7977; font-weight:bold; '>Statement</span> stm<span style='color:#808030; '>,</span> <span style='color:#bb7977; font-weight:bold; '>Connection</span> conn<span style='color:#808030; '>)</span>
    <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>rs <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
            <span style='color:#800000; font-weight:bold; '>try</span> <span style='color:#800080; '>{</span>
                rs<span style='color:#808030; '>.</span>close<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            <span style='color:#800080; '>}</span>
            <span style='color:#800000; font-weight:bold; '>catch</span> <span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>Exception</span> e<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span> <span style='color:#800080; '>}</span>
        <span style='color:#800080; '>}</span>

        <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>stm <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
            <span style='color:#800000; font-weight:bold; '>try</span> <span style='color:#800080; '>{</span>
                stm<span style='color:#808030; '>.</span>close<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            <span style='color:#800080; '>}</span>
            <span style='color:#800000; font-weight:bold; '>catch</span> <span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>Exception</span> e<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span> <span style='color:#800080; '>}</span>
        <span style='color:#800080; '>}</span>

        <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>conn <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
            <span style='color:#800000; font-weight:bold; '>try</span> <span style='color:#800080; '>{</span>
                conn<span style='color:#808030; '>.</span>close<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            <span style='color:#800080; '>}</span>
            <span style='color:#800000; font-weight:bold; '>catch</span> <span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>SQLException</span> e<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span> <span style='color:#800080; '>}</span>
        <span style='color:#800080; '>}</span>
    <span style='color:#800080; '>}</span>

    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>static</span> <span style='color:#bb7977; '>void</span> close<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>PreparedStatement</span> ps<span style='color:#808030; '>,</span> <span style='color:#bb7977; font-weight:bold; '>Connection</span> conn<span style='color:#808030; '>)</span>
    <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>ps <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
            <span style='color:#800000; font-weight:bold; '>try</span> <span style='color:#800080; '>{</span>
                ps<span style='color:#808030; '>.</span>close<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            <span style='color:#800080; '>}</span>
            <span style='color:#800000; font-weight:bold; '>catch</span> <span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>Exception</span> e<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span> <span style='color:#800080; '>}</span>
        <span style='color:#800080; '>}</span>

        <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>conn <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
            <span style='color:#800000; font-weight:bold; '>try</span> <span style='color:#800080; '>{</span>
                conn<span style='color:#808030; '>.</span>close<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            <span style='color:#800080; '>}</span>
            <span style='color:#800000; font-weight:bold; '>catch</span> <span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>SQLException</span> e<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span> <span style='color:#800080; '>}</span>
        <span style='color:#800080; '>}</span>
    <span style='color:#800080; '>}</span>

    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>static</span> <span style='color:#bb7977; '>void</span> close<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>ResultSet</span> rs<span style='color:#808030; '>)</span>
    <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>rs <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
            <span style='color:#800000; font-weight:bold; '>try</span> <span style='color:#800080; '>{</span>
                rs<span style='color:#808030; '>.</span>close<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            <span style='color:#800080; '>}</span>
            <span style='color:#800000; font-weight:bold; '>catch</span> <span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>Exception</span> e<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span> <span style='color:#800080; '>}</span>
        <span style='color:#800080; '>}</span>
    <span style='color:#800080; '>}</span>

    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>static</span> <span style='color:#bb7977; '>void</span> close<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>Statement</span> stm<span style='color:#808030; '>)</span>
    <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>stm <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
            <span style='color:#800000; font-weight:bold; '>try</span> <span style='color:#800080; '>{</span>
                stm<span style='color:#808030; '>.</span>close<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            <span style='color:#800080; '>}</span>
            <span style='color:#800000; font-weight:bold; '>catch</span> <span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>SQLException</span> e<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span> <span style='color:#800080; '>}</span>
        <span style='color:#800080; '>}</span>
    <span style='color:#800080; '>}</span>

    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>static</span> <span style='color:#bb7977; '>void</span> close<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>Connection</span> conn<span style='color:#808030; '>)</span>
    <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>conn <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
            <span style='color:#800000; font-weight:bold; '>try</span> <span style='color:#800080; '>{</span>
                conn<span style='color:#808030; '>.</span>close<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            <span style='color:#800080; '>}</span>
            <span style='color:#800000; font-weight:bold; '>catch</span> <span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>SQLException</span> e<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span> <span style='color:#800080; '>}</span>
        <span style='color:#800080; '>}</span>
    <span style='color:#800080; '>}</span>
<span style='color:#800080; '>}</span>
</pre>
</div>
<p><strong>struts-config.xml</strong> file is used for struts configuration. This xml file contains all details of application in struts form value action mapping</p>
<p>struts-config.xml</p>
<div class="cde"  style="overflow: auto; width: 570px;">
<pre><span style='color:#004a43; '>&lt;!</span><span style='color:#004a43; '>DOCTYPE</span> <span style='color:#004a43; '>struts-config</span> <span style='color:#800000; font-weight:bold; '>PUBLIC</span>  <span style='color:#0000e6; '>&quot;-//Apache Software Foundation//DTD Struts Configuration 1.3//EN&quot;</span>
          <span style='color:#0000e6; '>&quot;http://struts.apache.org/dtds/struts-config_1_3.dtd&quot;</span><span style='color:#004a43; '>></span>

    <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>struts-config</span><span style='color:#a65700; '>></span>

        <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>form-beans</span><span style='color:#a65700; '>></span>
            <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>form-bean</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>registerform</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>type</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>com.register.actions.UserRegisterForm</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>/></span>
        <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>form-beans</span><span style='color:#a65700; '>></span>

        <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>action-mappings</span><span style='color:#a65700; '>></span>
            <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>action</span>
                <span style='color:#274796; '>path</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>/doRegister</span><span style='color:#0000e6; '>&quot;</span>
                <span style='color:#274796; '>type</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>com.register.actions.UserRegistrationAction</span><span style='color:#0000e6; '>&quot;</span>
                <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>registerform</span><span style='color:#0000e6; '>&quot;</span>
                <span style='color:#274796; '>scope</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>request</span><span style='color:#0000e6; '>&quot;</span>
                <span style='color:#274796; '>validate</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>true</span><span style='color:#0000e6; '>&quot;</span>
                <span style='color:#274796; '>input</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>input</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
                <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>forward</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>input</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>path</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>/index.jsp</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>/></span>
                <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>forward</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>success</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>path</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>/welcome.jsp</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>/></span>
                <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>forward</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>failure</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>path</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>/index.jsp</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>/></span>
            <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>action</span><span style='color:#a65700; '>></span>

        <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>action-mappings</span><span style='color:#a65700; '>></span>

        <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>controller</span> <span style='color:#274796; '>inputForward</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>true</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#a65700; '>/></span>
        <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>message-resources</span> <span style='color:#274796; '>parameter</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>com.register.util.ApplicationResources</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>/></span>
        <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>plug-in</span> <span style='color:#274796; '>className</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>org.apache.struts.validator.ValidatorPlugIn</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
        <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>set-property</span> <span style='color:#274796; '>property</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>pathnames</span><span style='color:#0000e6; '>&quot;</span>
                      <span style='color:#274796; '>value</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>/org/apache/struts/validator/validator-rules.xml,</span>
<span style='color:#0000e6; '>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;/WEB-INF/validation.xml</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>/></span>
                      <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>set-property</span> <span style='color:#274796; '>property</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>stopOnFirstError</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>value</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>true</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#a65700; '>/></span>
        <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>plug-in</span><span style='color:#a65700; '>></span>
    <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>struts-config</span><span style='color:#a65700; '>></span>
</pre>
</div>
<p><strong>validation.xml</strong> is used for checking validate form value, if form is not validated properly it will throw error on user form.</p>
<p>validation.xml</p>
<div class="cde"  style="overflow: auto; width: 570px;">
<pre><span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>form-validation</span><span style='color:#a65700; '>></span>

  <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>formset</span><span style='color:#a65700; '>></span>
        <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>form</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>registerform</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
           <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>field</span> <span style='color:#274796; '>property</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>emailid</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>depends</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>required,email</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
            <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>msg</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>required</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>key</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>errors.user.registration.email</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>/></span>
            <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>msg</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>email</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>key</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>errors.user.registration.email.valid</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>/></span>
           <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>field</span><span style='color:#a65700; '>></span>
           <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>field</span> <span style='color:#274796; '>property</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>password</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>depends</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>required</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
            <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>msg</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>required</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>key</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>errors.user.registration.password</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>/></span>
           <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>field</span><span style='color:#a65700; '>></span>
           <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>field</span> <span style='color:#274796; '>property</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>cpassword</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>depends</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>required,validwhen</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
            <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>msg</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>required</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>key</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>errors.user.registration.password.confirm</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>/></span>
            <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>msg</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>validwhen</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>key</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>errors.user.registration.password.match</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#a65700; '>/></span>
               <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>var</span><span style='color:#a65700; '>></span>
                  <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>var-name</span><span style='color:#a65700; '>></span>test<span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>var-name</span><span style='color:#a65700; '>></span>
                  <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>var-value</span><span style='color:#a65700; '>></span>(password==cpassword)<span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>var-value</span><span style='color:#a65700; '>></span>
               <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>var</span><span style='color:#a65700; '>></span>
           <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>field</span><span style='color:#a65700; '>></span>
           <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>field</span> <span style='color:#274796; '>property</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>firstname</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>depends</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>required</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
            <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>msg</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>required</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>key</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>errors.user.registration.first.name</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>/></span>
           <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>field</span><span style='color:#a65700; '>></span>
           <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>field</span> <span style='color:#274796; '>property</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>lastname</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>depends</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>required</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
            <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>msg</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>required</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>key</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>errors.user.registration.last.name</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>/></span>
           <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>field</span><span style='color:#a65700; '>></span>
           <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>field</span> <span style='color:#274796; '>property</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>gender</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>depends</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>required</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
            <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>msg</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>required</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>key</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>errors.user.registration.gender</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>/></span>
           <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>field</span><span style='color:#a65700; '>></span>
           <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>field</span> <span style='color:#274796; '>property</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>submitError</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>depends</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>validwhen</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
             <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>msg</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>validwhen</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>key</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>errors.user.registration.fail</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#a65700; '>/></span>
           <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>var</span><span style='color:#a65700; '>></span>
              <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>var-name</span><span style='color:#a65700; '>></span>test<span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>var-name</span><span style='color:#a65700; '>></span>
               <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>var-value</span><span style='color:#a65700; '>></span>((emailid!=null) and ((password!=null) and ((cpassword!=null) and ((firstname!=null) and ((lastname!=null) and (gender!=null))))))<span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>var-value</span><span style='color:#a65700; '>></span>
           <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>var</span><span style='color:#a65700; '>></span>
          <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>field</span><span style='color:#a65700; '>></span>
        <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>form</span><span style='color:#a65700; '>></span>
  <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>formset</span><span style='color:#a65700; '>></span>

<span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>form-validation</span><span style='color:#a65700; '>></span>
</pre>
</div>
<p><strong>ApplicationResources.properties</strong> file is used for configuration and error </p>
<p>ApplicationResources.properties</p>
<div class="cde"  style="overflow: auto; width: 570px;">
<pre>
button.register=Register

# Database configuration setting
db.user=root
db.password=
db.host=localhost
db.dbname=reg_app

# errors

errors.user.registration.first.name=First Name cannot left empty
errors.user.registration.last.name=Last Name cannot left empty
errors.user.registration.password=Password cannot left empty
errors.user.registration.password.confirm=Confirm Password cannot left empty
errors.user.registration.password.match=Password &#038; Confirm password is not matched
errors.user.registration.email=Email cannot left empty
errors.user.registration.email.valid=Enter Valid Email ID e.g. myemailid@gmail.com
errors.user.registration.email.duplicate=Duplicate Email Found
errors.user.registration.gender=Select Gender

errors.user.registration.fail=Error found while registration user
errors.user.registration.success=Thank you for registration
</pre>
</div>
<p>Database table <strong>user_master</strong></p>
<div class="cde"  style="overflow: auto; width: 570px;">
<pre><span style='color:#800000; font-weight:bold; '>CREATE</span> <span style='color:#800000; font-weight:bold; '>TABLE</span> <span style='color:#800000; '>`</span><span style='color:#000000;'>user_master</span><span style='color:#800000; '>`</span> <span style='color:#808030; '>(</span>
  <span style='color:#800000; '>`</span><span style='color:#000000;'>iUID</span><span style='color:#800000; '>`</span> <span style='color:#bb7977; '>int</span><span style='color:#808030; '>(</span><span style='color:#008c00; '>10</span><span style='color:#808030; '>)</span> <span style='color:#074726; '>unsigned</span> <span style='color:#808030; '>NOT</span> <span style='color:#808030; '>NULL</span> <span style='color:#074726; '>auto_increment</span><span style='color:#800080; '>,</span>
  <span style='color:#800000; '>`</span><span style='color:#000000;'>sEmail</span><span style='color:#800000; '>`</span> <span style='color:#bb7977; '>varchar</span><span style='color:#808030; '>(</span><span style='color:#008c00; '>255</span><span style='color:#808030; '>)</span> <span style='color:#074726; '>default</span> <span style='color:#808030; '>NULL</span><span style='color:#800080; '>,</span>
  <span style='color:#800000; '>`</span><span style='color:#000000;'>sPassword</span><span style='color:#800000; '>`</span> <span style='color:#bb7977; '>varchar</span><span style='color:#808030; '>(</span><span style='color:#008c00; '>45</span><span style='color:#808030; '>)</span> <span style='color:#808030; '>NOT</span> <span style='color:#808030; '>NULL</span><span style='color:#800080; '>,</span>
  <span style='color:#800000; '>`</span><span style='color:#000000;'>sFirstName</span><span style='color:#800000; '>`</span> <span style='color:#bb7977; '>varchar</span><span style='color:#808030; '>(</span><span style='color:#008c00; '>45</span><span style='color:#808030; '>)</span> <span style='color:#074726; '>default</span> <span style='color:#808030; '>NULL</span><span style='color:#800080; '>,</span>
  <span style='color:#800000; '>`</span><span style='color:#000000;'>sLastName</span><span style='color:#800000; '>`</span> <span style='color:#bb7977; '>varchar</span><span style='color:#808030; '>(</span><span style='color:#008c00; '>45</span><span style='color:#808030; '>)</span> <span style='color:#074726; '>default</span> <span style='color:#808030; '>NULL</span><span style='color:#800080; '>,</span>
  <span style='color:#800000; '>`</span><span style='color:#000000;'>cGender</span><span style='color:#800000; '>`</span> <span style='color:#bb7977; '>char</span><span style='color:#808030; '>(</span><span style='color:#008c00; '>1</span><span style='color:#808030; '>)</span> <span style='color:#074726; '>default</span> <span style='color:#808030; '>NULL</span><span style='color:#800080; '>,</span>
  <span style='color:#800000; '>`</span><span style='color:#000000;'>iUserType</span><span style='color:#800000; '>`</span> <span style='color:#bb7977; '>int</span><span style='color:#808030; '>(</span><span style='color:#008c00; '>10</span><span style='color:#808030; '>)</span> <span style='color:#074726; '>unsigned</span> <span style='color:#074726; '>default</span> <span style='color:#808030; '>NULL</span><span style='color:#800080; '>,</span>
  <span style='color:#800000; '>`</span><span style='color:#000000;'>sForgetPassword</span><span style='color:#800000; '>`</span> <span style='color:#bb7977; '>varchar</span><span style='color:#808030; '>(</span><span style='color:#008c00; '>45</span><span style='color:#808030; '>)</span> <span style='color:#074726; '>default</span> <span style='color:#808030; '>NULL</span><span style='color:#800080; '>,</span>
  <span style='color:#800000; '>`</span><span style='color:#000000;'>sCreatedDate</span><span style='color:#800000; '>`</span> <span style='color:#bb7977; '>datetime</span> <span style='color:#074726; '>default</span> <span style='color:#808030; '>NULL</span><span style='color:#800080; '>,</span>
  <span style='color:#800000; '>`</span><span style='color:#000000;'>sLastLogin</span><span style='color:#800000; '>`</span> <span style='color:#bb7977; '>datetime</span> <span style='color:#074726; '>default</span> <span style='color:#808030; '>NULL</span><span style='color:#800080; '>,</span>
  <span style='color:#800000; '>`</span><span style='color:#000000;'>cStatus</span><span style='color:#800000; '>`</span> <span style='color:#bb7977; '>char</span><span style='color:#808030; '>(</span><span style='color:#008c00; '>1</span><span style='color:#808030; '>)</span> <span style='color:#074726; '>default</span> <span style='color:#808030; '>NULL</span><span style='color:#800080; '>,</span>
  <span style='color:#800000; font-weight:bold; '>PRIMARY</span> <span style='color:#800000; font-weight:bold; '>KEY</span>  <span style='color:#808030; '>(</span><span style='color:#800000; '>`</span><span style='color:#000000;'>iUID</span><span style='color:#800000; '>`</span><span style='color:#808030; '>)</span><span style='color:#800080; '>,</span>
  <span style='color:#800000; font-weight:bold; '>UNIQUE</span> <span style='color:#800000; font-weight:bold; '>KEY</span> <span style='color:#800000; '>`</span><span style='color:#000000;'>sEmail</span><span style='color:#800000; '>`</span> <span style='color:#808030; '>(</span><span style='color:#800000; '>`</span><span style='color:#000000;'>sEmail</span><span style='color:#800000; '>`</span><span style='color:#808030; '>)</span>
<span style='color:#808030; '>)</span> ENGINE<span style='color:#808030; '>=</span><span style='color:#074726; '>InnoDB</span> <span style='color:#074726; '>DEFAULT</span> CHARSET<span style='color:#808030; '>=</span>latin1<span style='color:#800080; '>;</span>
</pre>
</div>
<p><strong>JSP files</strong><br />
<strong>index.jsp</strong></p>
<div class="cde"  style="overflow: auto; width: 570px;">
<pre><span>&lt;%@</span><span style='color:#000000;'> page contentType=</span><span style='color:#0000e6;'>&quot;text/html; charset=iso-8859-1&quot;</span><span style='color:#000000;'> language=</span><span style='color:#0000e6;'>&quot;java&quot;</span><span style='color:#000000;'> </span><span>%></span>
<span>&lt;%@</span><span style='color:#000000;'> taglib uri=</span><span style='color:#0000e6;'>&quot;</span><span style='color:#5555dd;'>http://struts.apache.org/tags-bean</span><span style='color:#0000e6;'>&quot;</span><span style='color:#000000;'> prefix=</span><span style='color:#0000e6;'>&quot;bean&quot;</span><span style='color:#000000;'> </span><span>%></span>
<span>&lt;%@</span><span style='color:#000000;'> taglib uri=</span><span style='color:#0000e6;'>&quot;</span><span style='color:#5555dd;'>http://struts.apache.org/tags-html</span><span style='color:#0000e6;'>&quot;</span><span style='color:#000000;'> prefix=</span><span style='color:#0000e6;'>&quot;html&quot;</span><span style='color:#000000;'> </span><span>%></span>

<span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#5f5035; '>:</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#274796; '> </span><span style='color:#074726; '>lang</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;true&quot;</span><span style='color:#a65700; '>></span>
<span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>head</span><span style='color:#a65700; '>></span>
<span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>title</span><span style='color:#a65700; '>></span>User Registration Application<span style='color:#a65700; '>&lt;/</span><span style='color:#800000; font-weight:bold; '>title</span><span style='color:#a65700; '>></span>
<span style='color:#a65700; '>&lt;/</span><span style='color:#800000; font-weight:bold; '>head</span><span style='color:#a65700; '>></span>

<span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>body</span><span style='color:#a65700; '>></span>
<span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#5f5035; '>:errors</span><span style='color:#274796; '> property</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;submitError&quot;</span><span style='color:#a65700; '>/></span>

<span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#5f5035; '>:</span><span style='color:#800000; font-weight:bold; '>form</span><span style='color:#274796; '> </span><span style='color:#074726; '>action</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;doRegister&quot;</span><span style='color:#a65700; '>></span>
        Email: <span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#5f5035; '>:</span><span style='color:#800000; font-weight:bold; '>text</span><span style='color:#274796; '> property</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;emailid&quot;</span><span style='color:#274796; '> </span><span style='color:#a65700; '>/></span> <span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#5f5035; '>:errors</span><span style='color:#274796; '> property</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;emailid&quot;</span><span style='color:#a65700; '>/></span><span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>br</span><span style='color:#a65700; '>></span>
        Password: <span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#5f5035; '>:password</span><span style='color:#274796; '> property</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;password&quot;</span><span style='color:#274796; '> </span><span style='color:#a65700; '>/></span> <span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#5f5035; '>:errors</span><span style='color:#274796; '> property</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;password&quot;</span><span style='color:#a65700; '>/></span><span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>br</span><span style='color:#a65700; '>></span>
        Confirm Password: <span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#5f5035; '>:password</span><span style='color:#274796; '> property</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;cpassword&quot;</span><span style='color:#274796; '> </span><span style='color:#a65700; '>/></span> <span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#5f5035; '>:errors</span><span style='color:#274796; '> property</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;cpassword&quot;</span><span style='color:#a65700; '>/></span><span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>br</span><span style='color:#a65700; '>></span>
        First Name: <span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#5f5035; '>:</span><span style='color:#800000; font-weight:bold; '>text</span><span style='color:#274796; '> property</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;firstname&quot;</span><span style='color:#274796; '> </span><span style='color:#a65700; '>/></span> <span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#5f5035; '>:errors</span><span style='color:#274796; '> property</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;firstname&quot;</span><span style='color:#a65700; '>/></span><span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>br</span><span style='color:#a65700; '>></span>
        Last Name: <span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#5f5035; '>:</span><span style='color:#800000; font-weight:bold; '>text</span><span style='color:#274796; '> property</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;lastname&quot;</span><span style='color:#274796; '> </span><span style='color:#a65700; '>/></span> <span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#5f5035; '>:errors</span><span style='color:#274796; '> property</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;lastname&quot;</span><span style='color:#a65700; '>/></span><span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>br</span><span style='color:#a65700; '>></span>
        Gender: <span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#5f5035; '>:</span><span style='color:#800000; font-weight:bold; '>select</span><span style='color:#274796; '> property</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;gender&quot;</span><span style='color:#a65700; '>></span>
        <span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#5f5035; '>:</span><span style='color:#800000; font-weight:bold; '>option</span><span style='color:#274796; '> </span><span style='color:#074726; '>value</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;&quot;</span><span style='color:#a65700; '>></span>Select Gender<span style='color:#a65700; '>&lt;/</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#5f5035; '>:</span><span style='color:#800000; font-weight:bold; '>option</span><span style='color:#a65700; '>></span>
        <span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#5f5035; '>:</span><span style='color:#800000; font-weight:bold; '>option</span><span style='color:#274796; '> </span><span style='color:#074726; '>value</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;M&quot;</span><span style='color:#a65700; '>></span>Male<span style='color:#a65700; '>&lt;/</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#5f5035; '>:</span><span style='color:#800000; font-weight:bold; '>option</span><span style='color:#a65700; '>></span>
        <span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#5f5035; '>:</span><span style='color:#800000; font-weight:bold; '>option</span><span style='color:#274796; '> </span><span style='color:#074726; '>value</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;F&quot;</span><span style='color:#a65700; '>></span>Female<span style='color:#a65700; '>&lt;/</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#5f5035; '>:</span><span style='color:#800000; font-weight:bold; '>option</span><span style='color:#a65700; '>></span>
        <span style='color:#a65700; '>&lt;/</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#5f5035; '>:</span><span style='color:#800000; font-weight:bold; '>select</span><span style='color:#a65700; '>></span>
        <span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#5f5035; '>:errors</span><span style='color:#274796; '> property</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;gender&quot;</span><span style='color:#a65700; '>/></span><span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>br</span><span style='color:#a65700; '>></span>
        <span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#5f5035; '>:submit</span><span style='color:#a65700; '>></span><span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>bean:message</span><span style='color:#274796; '> key</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;button.register&quot;</span><span style='color:#a65700; '>/></span><span style='color:#a65700; '>&lt;/</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#5f5035; '>:submit</span><span style='color:#a65700; '>></span>
<span style='color:#a65700; '>&lt;/</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#5f5035; '>:</span><span style='color:#800000; font-weight:bold; '>form</span><span style='color:#a65700; '>></span>
<span style='color:#a65700; '>&lt;/</span><span style='color:#800000; font-weight:bold; '>body</span><span style='color:#a65700; '>></span>
<span style='color:#a65700; '>&lt;/</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#5f5035; '>:</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#a65700; '>></span>
</pre>
</div>
<p><strong>welcome.jsp</strong></p>
<div class="cde"  style="overflow: auto; width: 570px;">
<pre><span style='color:#a65700;'>&lt;%@</span><span style='color:#000000;'> page contentType=</span><span style='color:#0000e6;'>&quot;text/html; charset=iso-8859-1&quot;</span><span style='color:#000000;'> language=</span><span style='color:#0000e6;'>&quot;java&quot;</span><span style='color:#000000;'> </span><span style='color:#a65700;'>%></span>
<span style='color:#a65700;'>&lt;%@</span><span style='color:#000000;'> taglib uri=</span><span style='color:#0000e6;'>&quot;</span><span style='color:#5555dd;'>http://struts.apache.org/tags-bean</span><span style='color:#0000e6;'>&quot;</span><span style='color:#000000;'> prefix=</span><span style='color:#0000e6;'>&quot;bean&quot;</span><span style='color:#000000;'> </span><span style='color:#a65700;'>%></span>
<span style='color:#a65700;'>&lt;%@</span><span style='color:#000000;'> taglib uri=</span><span style='color:#0000e6;'>&quot;</span><span style='color:#5555dd;'>http://struts.apache.org/tags-html</span><span style='color:#0000e6;'>&quot;</span><span style='color:#000000;'> prefix=</span><span style='color:#0000e6;'>&quot;html&quot;</span><span style='color:#000000;'> </span><span style='color:#a65700;'>%></span>
<span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#a65700; '>></span>
<span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>head</span><span style='color:#a65700; '>></span>
<span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>title</span><span style='color:#a65700; '>></span>Welcome Registered successfully<span style='color:#a65700; '>&lt;/</span><span style='color:#800000; font-weight:bold; '>title</span><span style='color:#a65700; '>></span>
<span style='color:#a65700; '>&lt;/</span><span style='color:#800000; font-weight:bold; '>head</span><span style='color:#a65700; '>></span>

<span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>body</span><span style='color:#a65700; '>></span>
<span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#5f5035; '>:errors</span><span style='color:#274796; '> property</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;submitError&quot;</span><span style='color:#a65700; '>/></span>
<span style='color:#a65700; '>&lt;/</span><span style='color:#800000; font-weight:bold; '>body</span><span style='color:#a65700; '>></span>
<span style='color:#a65700; '>&lt;/</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#a65700; '>></span>
</pre>
</div>
<p><strong>2. Deploy project in tomcat or jBoss</strong></p>
<p><strong>3. Run application in browser</strong></p>
<p><a href="http://www.easywayserver.com/sourcecode/registrationapplication.zip"><strong>Download User Registration application</strong></a></p>
<div id="crp_related"><h3>Related Posts:</h3><ul style="list-style:disc;padding-left:20px"><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/building-a-login-application/" rel="bookmark" class="crp_title">Building a Login Application</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts-dynaform-validation/" rel="bookmark" class="crp_title">Struts &#8211; DynaForm validation</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts-iterator-database-fetching-example/" rel="bookmark" class="crp_title">Struts iterator database fetching example</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts2-validation-example-struts-2-validation/" rel="bookmark" class="crp_title">Struts2 &#8211; Validation Example, Struts 2 Validation</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/upload-file-in-struts/" rel="bookmark" class="crp_title">Upload file in struts</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/java-read-xml-taglib-and-jstl-in-jsp/" rel="bookmark" class="crp_title">JAVA &#8211; Read XML Taglib and JSTL in JSP</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.easywayserver.com/blog/building-a-user-registration-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building a Login Application</title>
		<link>http://www.easywayserver.com/blog/building-a-login-application/</link>
		<comments>http://www.easywayserver.com/blog/building-a-login-application/#comments</comments>
		<pubDate>Sun, 17 Oct 2010 12:54:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Struts]]></category>

		<guid isPermaLink="false">http://www.easywayserver.com/blog/?p=591</guid>
		<description><![CDATA[Most of web application today having login facilities. This tutorial is giving you a rough idea to develop login application for your application. This login application can be easily integrated with your old application.  This login application is based on MVC pattern and build on struts framework. Application is containing three packages actions, model [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.easywayserver.com%2Fblog%2Fbuilding-a-login-application%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.easywayserver.com%2Fblog%2Fbuilding-a-login-application%2F" height="61" width="51" /></a></div><p>Most of web application today having login facilities. This tutorial is giving you a rough idea to develop login application for your application. This login application can be easily integrated with your old application.  This login application is based on MVC pattern and build on struts framework. Application is containing three packages actions, model and util. actions package contains all those class which are action class of struts and formbean actionform classes. Model package contain all those classes which are used for logical part and business part. Util package contain only those classes to give helping to application, e.g. Database connection classes, closing object classes and properties file.</p>
<p>
<h3>Steps to developing user login application</h3>
</p>
<p><strong>1. Create a project in eclipse</strong></p>
<p>After creating a project in eclipse, now understand the flow of application. </p>
<p><strong>UserAuthAction.java</strong> is action class of struts, this class authenticate user’s login and perform action according to the result. This is mainly use for user authentication.</p>
<p>UserAuthAction.java</p>
<div class="cde">
<pre><span style='color:#800000; font-weight:bold; '>package</span><span style='color:#004a43; '> com</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>login</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>actions</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> javax</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>servlet</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>http</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>HttpServletRequest</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> javax</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>servlet</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>http</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>HttpServletResponse</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> org</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>apache</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>struts</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>action</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>Action</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> org</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>apache</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>struts</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>action</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>ActionForm</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> org</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>apache</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>struts</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>action</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>ActionForward</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> org</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>apache</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>struts</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>action</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>ActionMapping</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> org</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>apache</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>struts</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>action</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>ActionMessage</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> org</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>apache</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>struts</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>action</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>ActionMessages</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> com</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>login</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>model</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>UserLogin</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>class</span> UserAuthAction <span style='color:#800000; font-weight:bold; '>extends</span> Action<span style='color:#800080; '>{</span>

    <span style='color:#800000; font-weight:bold; '>public</span> ActionForward execute<span style='color:#808030; '>(</span>ActionMapping mapping<span style='color:#808030; '>,</span>
                                 ActionForm form<span style='color:#808030; '>,</span>
                                 HttpServletRequest request<span style='color:#808030; '>,</span>
                                 HttpServletResponse response<span style='color:#808030; '>)</span>
    <span style='color:#800000; font-weight:bold; '>throws</span> <span style='color:#bb7977; font-weight:bold; '>Exception</span>
    <span style='color:#800080; '>{</span>
        <span style='color:#bb7977; '>boolean</span> action_perform<span style='color:#808030; '>=</span><span style='color:#800000; font-weight:bold; '>false</span><span style='color:#800080; '>;</span>
        <span style='color:#bb7977; font-weight:bold; '>String</span> action_target<span style='color:#800080; '>;</span>

        UserLogin u <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> UserLogin<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        ActionMessages errors_mesg <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> ActionMessages<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        UserForm uf <span style='color:#808030; '>=</span> <span style='color:#808030; '>(</span>UserForm<span style='color:#808030; '>)</span>form<span style='color:#800080; '>;</span>

        <span style='color:#800000; font-weight:bold; '>if</span><span style='color:#808030; '>(</span>form<span style='color:#808030; '>!</span><span style='color:#808030; '>=</span><span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span><span style='color:#800080; '>{</span>
            u<span style='color:#808030; '>.</span>setUsername<span style='color:#808030; '>(</span>uf<span style='color:#808030; '>.</span>getUsername<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            u<span style='color:#808030; '>.</span>setPassword<span style='color:#808030; '>(</span>uf<span style='color:#808030; '>.</span>getPassword<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            action_perform <span style='color:#808030; '>=</span> u<span style='color:#808030; '>.</span>doLogin<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#800080; '>}</span>
        <span style='color:#800000; font-weight:bold; '>if</span><span style='color:#808030; '>(</span>action_perform<span style='color:#808030; '>=</span><span style='color:#808030; '>=</span><span style='color:#800000; font-weight:bold; '>false</span><span style='color:#808030; '>)</span><span style='color:#800080; '>{</span>
            errors_mesg<span style='color:#808030; '>.</span>add<span style='color:#808030; '>(</span><span style='color:#0000e6; '>&quot;submitError&quot;</span><span style='color:#808030; '>,</span>
			                    <span style='color:#800000; font-weight:bold; '>new</span> ActionMessage<span style='color:#808030; '>(</span><span style='color:#0000e6; '>&quot;errors.login.fail&quot;</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            saveErrors<span style='color:#808030; '>(</span>request<span style='color:#808030; '>,</span>errors_mesg<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

            action_target<span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;failure&quot;</span><span style='color:#800080; '>;</span>
        <span style='color:#800080; '>}</span>
        <span style='color:#800000; font-weight:bold; '>else</span><span style='color:#800080; '>{</span>
            action_target<span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;success&quot;</span><span style='color:#800080; '>;</span>
        <span style='color:#800080; '>}</span>

        <span style='color:#800000; font-weight:bold; '>return</span> mapping<span style='color:#808030; '>.</span>findForward<span style='color:#808030; '>(</span>action_target<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
<span style='color:#800080; '>}</span>
</pre>
</div>
<p><strong>UserLogin.java</strong> is logical business class, this class checks username and password in database and if matched with database and user enter value, it will throw true in Boolean value. </p>
<p>UserLogin.java</p>
<div class="cde">
<pre><span style='color:#800000; font-weight:bold; '>package</span><span style='color:#004a43; '> com</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>login</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>model</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> java</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>sql</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>Connection</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> java</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>sql</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>PreparedStatement</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> java</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>sql</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>ResultSet</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> com</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>login</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>util</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>DbUtils</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> com</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>login</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>util</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>ConnectionUtils</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>class</span> UserLogin <span style='color:#800000; font-weight:bold; '>extends</span> User<span style='color:#800080; '>{</span>

    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#800000; font-weight:bold; '>static</span> <span style='color:#800000; font-weight:bold; '>final</span> <span style='color:#bb7977; '>long</span> serialVersionUID <span style='color:#808030; '>=</span> <span style='color:#008c00; '>1</span><span style='color:#006600; '>L</span><span style='color:#800080; '>;</span>

    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>boolean</span> doLogin<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800000; font-weight:bold; '>throws</span> <span style='color:#bb7977; font-weight:bold; '>Exception</span>
    <span style='color:#800080; '>{</span>
        <span style='color:#bb7977; font-weight:bold; '>PreparedStatement</span> psDoLogin <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#800080; '>;</span>
        <span style='color:#bb7977; font-weight:bold; '>ResultSet</span> rsDoLogin <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#800080; '>;</span>
        <span style='color:#bb7977; font-weight:bold; '>String</span> sqlDoLogin <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#800080; '>;</span>

        <span style='color:#bb7977; '>boolean</span> isLoginValidate <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>false</span><span style='color:#800080; '>;</span>

        <span style='color:#bb7977; font-weight:bold; '>Connection</span> conn <span style='color:#808030; '>=</span> ConnectionUtils<span style='color:#808030; '>.</span>getConnection<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        sqlDoLogin <span style='color:#808030; '>=</span> <span style='color:#0000e6; '>&quot;Select * from user_registration &quot;</span> <span style='color:#808030; '>+</span>
                     <span style='color:#0000e6; '>&quot;  where sUserID=? and sPassword=password(?)&quot;</span><span style='color:#800080; '>;</span>

        psDoLogin <span style='color:#808030; '>=</span> conn<span style='color:#808030; '>.</span>prepareStatement<span style='color:#808030; '>(</span>sqlDoLogin<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        psDoLogin<span style='color:#808030; '>.</span>setString<span style='color:#808030; '>(</span><span style='color:#008c00; '>1</span><span style='color:#808030; '>,</span> <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>getUsername<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        psDoLogin<span style='color:#808030; '>.</span>setString<span style='color:#808030; '>(</span><span style='color:#008c00; '>2</span><span style='color:#808030; '>,</span> <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>getPassword<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        rsDoLogin <span style='color:#808030; '>=</span> psDoLogin<span style='color:#808030; '>.</span>executeQuery<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        <span style='color:#800000; font-weight:bold; '>if</span><span style='color:#808030; '>(</span>rsDoLogin<span style='color:#808030; '>.</span>next<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span>
        <span style='color:#800080; '>{</span>
            isLoginValidate <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>true</span><span style='color:#800080; '>;</span>
        <span style='color:#800080; '>}</span>

        DbUtils<span style='color:#808030; '>.</span>close<span style='color:#808030; '>(</span>rsDoLogin<span style='color:#808030; '>,</span> psDoLogin<span style='color:#808030; '>,</span> conn<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        <span style='color:#800000; font-weight:bold; '>return</span> isLoginValidate<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
<span style='color:#800080; '>}</span>
</pre>
</div>
<p><strong>User.java</strong> is simple pojo class</p>
<p>User.java</p>
<div class="cde">
<pre><span style='color:#800000; font-weight:bold; '>package</span><span style='color:#004a43; '> com</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>login</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>model</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> java</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>io</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>Serializable</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> java</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>util</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>Date</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>class</span> User <span style='color:#800000; font-weight:bold; '>implements</span> Serializable<span style='color:#800080; '>{</span>

    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#800000; font-weight:bold; '>static</span> <span style='color:#800000; font-weight:bold; '>final</span> <span style='color:#bb7977; '>long</span> serialVersionUID <span style='color:#808030; '>=</span> <span style='color:#008c00; '>1</span><span style='color:#006600; '>L</span><span style='color:#800080; '>;</span>

    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; '>int</span> id<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; '>int</span> level<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> username<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> password<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>Date</span> lastVisit<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>Date</span> registrationDate<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> email<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> webSite<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> occupation<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> gender<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> timeZone<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> dateFormat<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; '>int</span> active<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> activationKey<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; '>int</span> deleted<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> firstName<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> lastName<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> ipAddress<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> macAddress<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; '>int</span> failLoginAttempted<span style='color:#800080; '>;</span>

    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getActivationKey<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> activationKey<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setActivationKey<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> activationKey<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>activationKey <span style='color:#808030; '>=</span> activationKey<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>int</span> getActive<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> active<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setActive<span style='color:#808030; '>(</span><span style='color:#bb7977; '>int</span> active<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>active <span style='color:#808030; '>=</span> active<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getDateFormat<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> dateFormat<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setDateFormat<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> dateFormat<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>dateFormat <span style='color:#808030; '>=</span> dateFormat<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>int</span> getDeleted<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> deleted<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setDeleted<span style='color:#808030; '>(</span><span style='color:#bb7977; '>int</span> deleted<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>deleted <span style='color:#808030; '>=</span> deleted<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getEmail<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> email<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setEmail<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> email<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>email <span style='color:#808030; '>=</span> email<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>int</span> getFailLoginAttempted<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> failLoginAttempted<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setFailLoginAttempted<span style='color:#808030; '>(</span><span style='color:#bb7977; '>int</span> failLoginAttempted<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>failLoginAttempted <span style='color:#808030; '>=</span> failLoginAttempted<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getFirstName<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> firstName<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setFirstName<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> firstName<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>firstName <span style='color:#808030; '>=</span> firstName<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getGender<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> gender<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setGender<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> gender<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>gender <span style='color:#808030; '>=</span> gender<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>int</span> getId<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> id<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setId<span style='color:#808030; '>(</span><span style='color:#bb7977; '>int</span> id<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>id <span style='color:#808030; '>=</span> id<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getIpAddress<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> ipAddress<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setIpAddress<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> ipAddress<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>ipAddress <span style='color:#808030; '>=</span> ipAddress<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getLastName<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> lastName<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setLastName<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> lastName<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>lastName <span style='color:#808030; '>=</span> lastName<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>Date</span> getLastVisit<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> lastVisit<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setLastVisit<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>Date</span> lastVisit<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>lastVisit <span style='color:#808030; '>=</span> lastVisit<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>int</span> getLevel<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> level<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setLevel<span style='color:#808030; '>(</span><span style='color:#bb7977; '>int</span> level<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>level <span style='color:#808030; '>=</span> level<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getMacAddress<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> macAddress<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setMacAddress<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> macAddress<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>macAddress <span style='color:#808030; '>=</span> macAddress<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getOccupation<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> occupation<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setOccupation<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> occupation<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>occupation <span style='color:#808030; '>=</span> occupation<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getPassword<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> password<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setPassword<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> password<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>password <span style='color:#808030; '>=</span> password<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>Date</span> getRegistrationDate<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> registrationDate<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setRegistrationDate<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>Date</span> registrationDate<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>registrationDate <span style='color:#808030; '>=</span> registrationDate<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getTimeZone<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> timeZone<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setTimeZone<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> timeZone<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>timeZone <span style='color:#808030; '>=</span> timeZone<span style='color:#800080; '>;</span>

    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getUsername<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> username<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setUsername<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> username<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>username <span style='color:#808030; '>=</span> username<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getWebSite<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> webSite<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setWebSite<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> webSite<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>webSite <span style='color:#808030; '>=</span> webSite<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
<span style='color:#800080; '>}</span>
</pre>
</div>
<p><strong>UserForm.java</strong> is ActionForm class of struts</p>
<p>UserForm.java</p>
<div class="cde">
<pre><span style='color:#800000; font-weight:bold; '>package</span><span style='color:#004a43; '> com</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>login</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>actions</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> org</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>apache</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>struts</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>validator</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>ValidatorForm</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>class</span> UserForm <span style='color:#800000; font-weight:bold; '>extends</span> ValidatorForm<span style='color:#800080; '>{</span>

    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#800000; font-weight:bold; '>static</span> <span style='color:#800000; font-weight:bold; '>final</span> <span style='color:#bb7977; '>long</span> serialVersionUID <span style='color:#808030; '>=</span> <span style='color:#008c00; '>1</span><span style='color:#006600; '>L</span><span style='color:#800080; '>;</span>

    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> username<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> password<span style='color:#800080; '>;</span>

    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getPassword<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> password<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setPassword<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> password<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>password <span style='color:#808030; '>=</span> password<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getUsername<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> username<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setUsername<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> username<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>username <span style='color:#808030; '>=</span> username<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
<span style='color:#800080; '>}</span>
</pre>
</div>
<p><strong>ConnectionUtils.java</strong> class is used to create database connections</p>
<p>ConnectionUtils.java</p>
<div class="cde">
<pre><span style='color:#800000; font-weight:bold; '>package</span><span style='color:#004a43; '> com</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>login</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>util</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> java</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>sql</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>Connection</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> java</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>sql</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>DriverManager</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>class</span> ConnectionUtils <span style='color:#800080; '>{</span>

    <span style='color:#800000; font-weight:bold; '>static</span><span style='color:#800080; '>{</span>
          <span style='color:#800000; font-weight:bold; '>try</span> <span style='color:#800080; '>{</span>
                 <span style='color:#bb7977; font-weight:bold; '>Class</span><span style='color:#808030; '>.</span>forName<span style='color:#808030; '>(</span><span style='color:#0000e6; '>&quot;com.mysql.jdbc.Driver&quot;</span><span style='color:#808030; '>)</span><span style='color:#808030; '>.</span>newInstance<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
          <span style='color:#800080; '>}</span> <span style='color:#800000; font-weight:bold; '>catch</span> <span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>Exception</span> ex<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
          <span style='color:#800080; '>}</span>
    <span style='color:#800080; '>}</span>

    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>static</span> <span style='color:#bb7977; font-weight:bold; '>Connection</span> getConnection<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800000; font-weight:bold; '>throws</span> <span style='color:#bb7977; font-weight:bold; '>Exception</span>
    <span style='color:#800080; '>{</span>
           <span style='color:#800000; font-weight:bold; '>return</span> getDBConnection<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>

     <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>static</span> <span style='color:#bb7977; font-weight:bold; '>Connection</span> getDBConnection<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800000; font-weight:bold; '>throws</span> <span style='color:#bb7977; font-weight:bold; '>Exception</span>
      <span style='color:#800080; '>{</span>
          <span style='color:#bb7977; font-weight:bold; '>Connection</span> conn <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#800080; '>;</span>
          <span style='color:#bb7977; font-weight:bold; '>String</span> URLPath<span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;jdbc:mysql://localhost:3306/login_app&quot;</span><span style='color:#800080; '>;</span>
          <span style='color:#bb7977; font-weight:bold; '>String</span> dbUser<span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;yourUserName&quot;</span><span style='color:#800080; '>;</span>
          <span style='color:#bb7977; font-weight:bold; '>String</span> dbPassword<span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;yourPassword&quot;</span><span style='color:#800080; '>;</span>
          <span style='color:#800000; font-weight:bold; '>try</span><span style='color:#800080; '>{</span>
            conn <span style='color:#808030; '>=</span> <span style='color:#bb7977; font-weight:bold; '>DriverManager</span><span style='color:#808030; '>.</span>getConnection<span style='color:#808030; '>(</span>URLPath<span style='color:#808030; '>,</span>dbUser<span style='color:#808030; '>,</span> dbPassword<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
          <span style='color:#800080; '>}</span>
          <span style='color:#800000; font-weight:bold; '>catch</span><span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>Exception</span> e<span style='color:#808030; '>)</span>
          <span style='color:#800080; '>{</span>
              e<span style='color:#808030; '>.</span>printStackTrace<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
          <span style='color:#800080; '>}</span>

          <span style='color:#800000; font-weight:bold; '>return</span> conn<span style='color:#800080; '>;</span>
      <span style='color:#800080; '>}</span>
<span style='color:#800080; '>}</span>
</pre>
</div>
<p><strong>DbUtils.java</strong> class is used for to close database objects which can be resultset, prepareStatement or Connection.</p>
<p>DbUtils.java</p>
<div class="cde">
<pre><span style='color:#800000; font-weight:bold; '>package</span><span style='color:#004a43; '> com</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>login</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>util</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> java</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>sql</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>Connection</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> java</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>sql</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>ResultSet</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> java</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>sql</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>SQLException</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> java</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>sql</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>Statement</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>class</span> DbUtils <span style='color:#800080; '>{</span>

    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>static</span> <span style='color:#bb7977; '>void</span> close<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>ResultSet</span> rs<span style='color:#808030; '>,</span> <span style='color:#bb7977; font-weight:bold; '>Statement</span> stm<span style='color:#808030; '>)</span>
    <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>rs <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
            <span style='color:#800000; font-weight:bold; '>try</span> <span style='color:#800080; '>{</span>
                rs<span style='color:#808030; '>.</span>close<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            <span style='color:#800080; '>}</span>
            <span style='color:#800000; font-weight:bold; '>catch</span> <span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>Exception</span> e<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span> <span style='color:#800080; '>}</span>
        <span style='color:#800080; '>}</span>

        <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>stm <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
            <span style='color:#800000; font-weight:bold; '>try</span> <span style='color:#800080; '>{</span>
                stm<span style='color:#808030; '>.</span>close<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            <span style='color:#800080; '>}</span>
            <span style='color:#800000; font-weight:bold; '>catch</span> <span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>Exception</span> e<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span> <span style='color:#800080; '>}</span>
        <span style='color:#800080; '>}</span>
    <span style='color:#800080; '>}</span>

    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>static</span> <span style='color:#bb7977; '>void</span> close<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>ResultSet</span> rs<span style='color:#808030; '>,</span> <span style='color:#bb7977; font-weight:bold; '>Statement</span> stm<span style='color:#808030; '>,</span> <span style='color:#bb7977; font-weight:bold; '>Connection</span> conn<span style='color:#808030; '>)</span>
    <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>rs <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
            <span style='color:#800000; font-weight:bold; '>try</span> <span style='color:#800080; '>{</span>
                rs<span style='color:#808030; '>.</span>close<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            <span style='color:#800080; '>}</span>
            <span style='color:#800000; font-weight:bold; '>catch</span> <span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>Exception</span> e<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span> <span style='color:#800080; '>}</span>
        <span style='color:#800080; '>}</span>

        <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>stm <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
            <span style='color:#800000; font-weight:bold; '>try</span> <span style='color:#800080; '>{</span>
                stm<span style='color:#808030; '>.</span>close<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            <span style='color:#800080; '>}</span>
            <span style='color:#800000; font-weight:bold; '>catch</span> <span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>Exception</span> e<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span> <span style='color:#800080; '>}</span>
        <span style='color:#800080; '>}</span>

        <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>conn <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
            <span style='color:#800000; font-weight:bold; '>try</span> <span style='color:#800080; '>{</span>
                conn<span style='color:#808030; '>.</span>close<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            <span style='color:#800080; '>}</span>
            <span style='color:#800000; font-weight:bold; '>catch</span> <span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>SQLException</span> e<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span> <span style='color:#800080; '>}</span>
        <span style='color:#800080; '>}</span>
    <span style='color:#800080; '>}</span>

    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>static</span> <span style='color:#bb7977; '>void</span> close<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>ResultSet</span> rs<span style='color:#808030; '>)</span>
    <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>rs <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
            <span style='color:#800000; font-weight:bold; '>try</span> <span style='color:#800080; '>{</span>
                rs<span style='color:#808030; '>.</span>close<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            <span style='color:#800080; '>}</span>
            <span style='color:#800000; font-weight:bold; '>catch</span> <span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>Exception</span> e<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span> <span style='color:#800080; '>}</span>
        <span style='color:#800080; '>}</span>
    <span style='color:#800080; '>}</span>

    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>static</span> <span style='color:#bb7977; '>void</span> close<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>Statement</span> stm<span style='color:#808030; '>)</span>
    <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>stm <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
            <span style='color:#800000; font-weight:bold; '>try</span> <span style='color:#800080; '>{</span>
                stm<span style='color:#808030; '>.</span>close<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            <span style='color:#800080; '>}</span>
            <span style='color:#800000; font-weight:bold; '>catch</span> <span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>SQLException</span> e<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span> <span style='color:#800080; '>}</span>
        <span style='color:#800080; '>}</span>
    <span style='color:#800080; '>}</span>

    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>static</span> <span style='color:#bb7977; '>void</span> close<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>Connection</span> conn<span style='color:#808030; '>)</span>
    <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>conn <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
            <span style='color:#800000; font-weight:bold; '>try</span> <span style='color:#800080; '>{</span>
                conn<span style='color:#808030; '>.</span>close<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            <span style='color:#800080; '>}</span>
            <span style='color:#800000; font-weight:bold; '>catch</span> <span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>SQLException</span> e<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span> <span style='color:#800080; '>}</span>
        <span style='color:#800080; '>}</span>
    <span style='color:#800080; '>}</span>
<span style='color:#800080; '>}</span>
</pre>
</div>
<p><strong>struts-config.xml</strong> file is used for struts configuration. This xml file contains all details of application in struts form value action mapping</p>
<p>struts-config.xml</p>
<div class="cde">
<pre><span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>struts-config</span><span style='color:#a65700; '>></span>

        <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>form-beans</span><span style='color:#a65700; '>></span>
            <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>form-bean</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>loginform</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>type</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>com.login.actions.UserForm</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>/></span>
        <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>form-beans</span><span style='color:#a65700; '>></span>

        <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>action-mappings</span><span style='color:#a65700; '>></span>
            <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>action</span>
                <span style='color:#274796; '>path</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>/doLogin</span><span style='color:#0000e6; '>&quot;</span>
                <span style='color:#274796; '>type</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>com.login.actions.UserAuthAction</span><span style='color:#0000e6; '>&quot;</span>
                <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>loginform</span><span style='color:#0000e6; '>&quot;</span>
                <span style='color:#274796; '>scope</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>request</span><span style='color:#0000e6; '>&quot;</span>
                <span style='color:#274796; '>validate</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>true</span><span style='color:#0000e6; '>&quot;</span>
                <span style='color:#274796; '>input</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>input</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
                <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>forward</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>input</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>path</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>/index.jsp</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>/></span>
                <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>forward</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>success</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>path</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>/welcome.jsp</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>/></span>
                <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>forward</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>failure</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>path</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>/index.jsp</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>/></span>
            <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>action</span><span style='color:#a65700; '>></span>

        <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>action-mappings</span><span style='color:#a65700; '>></span>

        <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>controller</span> <span style='color:#274796; '>inputForward</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>true</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#a65700; '>/></span>
        <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>message-resources</span> <span style='color:#274796; '>parameter</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>com.login.util.ApplicationResources</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>/></span>
        <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>plug-in</span> <span style='color:#274796; '>className</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>org.apache.struts.validator.ValidatorPlugIn</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
        <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>set-property</span> <span style='color:#274796; '>property</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>pathnames</span><span style='color:#0000e6; '>&quot;</span>
                      <span style='color:#274796; '>value</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>/org/apache/struts/validator/validator-rules.xml,</span>
<span style='color:#0000e6; '>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;/WEB-INF/validation.xml</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>/></span>
                      <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>set-property</span> <span style='color:#274796; '>property</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>stopOnFirstError</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>value</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>true</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#a65700; '>/></span>
        <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>plug-in</span><span style='color:#a65700; '>></span>
    <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>struts-config</span><span style='color:#a65700; '>></span>
</pre>
</div>
<p><strong>validation.xml</strong> is used for checking validate form value, if form is not validated properly it will throw error on user form.</p>
<p>validation.xml</p>
<div class="cde">
<pre><span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>form-validation</span><span style='color:#a65700; '>></span>

  <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>formset</span><span style='color:#a65700; '>></span>
        <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>form</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>loginform</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
           <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>field</span> <span style='color:#274796; '>property</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>username</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>depends</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>required</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
            <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>msg</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>required</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>key</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>errors.login.name</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>/></span>
           <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>field</span><span style='color:#a65700; '>></span>
           <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>field</span> <span style='color:#274796; '>property</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>password</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>depends</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>required</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
            <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>msg</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>required</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>key</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>errors.login.password</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>/></span>
           <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>field</span><span style='color:#a65700; '>></span>
           <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>field</span> <span style='color:#274796; '>property</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>submitError</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>depends</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>validwhen</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
             <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>msg</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>validwhen</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>key</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>errors.login.fail</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#a65700; '>/></span>
           <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>var</span><span style='color:#a65700; '>></span>
              <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>var-name</span><span style='color:#a65700; '>></span>test<span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>var-name</span><span style='color:#a65700; '>></span>
              <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>var-value</span><span style='color:#a65700; '>></span>((username!=null) and (password!=null))<span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>var-value</span><span style='color:#a65700; '>></span>
           <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>var</span><span style='color:#a65700; '>></span>
          <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>field</span><span style='color:#a65700; '>></span>
        <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>form</span><span style='color:#a65700; '>></span>
  <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>formset</span><span style='color:#a65700; '>></span>

<span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>form-validation</span><span style='color:#a65700; '>></span>
</pre>
</div>
<p><strong>ApplicationResources.properties</strong> file is used for configuration and error </p>
<p>ApplicationResources.properties</p>
<div class="cde">
<pre>
button.login=Login

# errors

errors.login.fail=Incorrect login parameter
errors.login.name=Please fill name
errors.login.password=Please fill password
</pre>
</div>
<p>Database table <strong>user_registration</strong></p>
<div class="cde">
<pre><span style='color:#800000; font-weight:bold; '>CREATE</span> <span style='color:#800000; font-weight:bold; '>TABLE</span>  <span style='color:#800000; '>`</span><span >login_app</span><span style='color:#800000; '>`</span><span style='color:#808030; '>.</span><span style='color:#800000; '>`</span><span >user_registration</span><span style='color:#800000; '>`</span> <span style='color:#808030; '>(</span>
  <span style='color:#800000; '>`</span><span >id</span><span style='color:#800000; '>`</span> <span style='color:#bb7977; '>int</span><span style='color:#808030; '>(</span><span style='color:#008c00; '>10</span><span style='color:#808030; '>)</span> <span style='color:#074726; '>unsigned</span> <span style='color:#808030; '>NOT</span> <span style='color:#808030; '>NULL</span> <span style='color:#074726; '>auto_increment</span><span style='color:#800080; '>,</span>
  <span style='color:#800000; '>`</span><span >sUserID</span><span style='color:#800000; '>`</span> <span style='color:#bb7977; '>varchar</span><span style='color:#808030; '>(</span><span style='color:#008c00; '>45</span><span style='color:#808030; '>)</span> <span style='color:#808030; '>NOT</span> <span style='color:#808030; '>NULL</span><span style='color:#800080; '>,</span>
  <span style='color:#800000; '>`</span><span >sPassword</span><span style='color:#800000; '>`</span> <span style='color:#bb7977; '>varchar</span><span style='color:#808030; '>(</span><span style='color:#008c00; '>45</span><span style='color:#808030; '>)</span> <span style='color:#808030; '>NOT</span> <span style='color:#808030; '>NULL</span><span style='color:#800080; '>,</span>
  <span style='color:#800000; '>`</span><span >sFirstName</span><span style='color:#800000; '>`</span> <span style='color:#bb7977; '>varchar</span><span style='color:#808030; '>(</span><span style='color:#008c00; '>45</span><span style='color:#808030; '>)</span> <span style='color:#074726; '>default</span> <span style='color:#808030; '>NULL</span><span style='color:#800080; '>,</span>
  <span style='color:#800000; '>`</span><span >sLastName</span><span style='color:#800000; '>`</span> <span style='color:#bb7977; '>varchar</span><span style='color:#808030; '>(</span><span style='color:#008c00; '>45</span><span style='color:#808030; '>)</span> <span style='color:#074726; '>default</span> <span style='color:#808030; '>NULL</span><span style='color:#800080; '>,</span>
  <span style='color:#800000; '>`</span><span >sEmail</span><span style='color:#800000; '>`</span> <span style='color:#bb7977; '>varchar</span><span style='color:#808030; '>(</span><span style='color:#008c00; '>45</span><span style='color:#808030; '>)</span> <span style='color:#074726; '>default</span> <span style='color:#808030; '>NULL</span><span style='color:#800080; '>,</span>
  <span style='color:#800000; '>`</span><span >cGender</span><span style='color:#800000; '>`</span> <span style='color:#bb7977; '>char</span><span style='color:#808030; '>(</span><span style='color:#008c00; '>1</span><span style='color:#808030; '>)</span> <span style='color:#074726; '>default</span> <span style='color:#808030; '>NULL</span><span style='color:#800080; '>,</span>
  <span style='color:#800000; '>`</span><span >sUserGroup</span><span style='color:#800000; '>`</span> <span style='color:#bb7977; '>varchar</span><span style='color:#808030; '>(</span><span style='color:#008c00; '>45</span><span style='color:#808030; '>)</span> <span style='color:#074726; '>default</span> <span style='color:#808030; '>NULL</span><span style='color:#800080; '>,</span>
  <span style='color:#800000; '>`</span><span >sCreatedDate</span><span style='color:#800000; '>`</span> <span style='color:#bb7977; '>datetime</span> <span style='color:#074726; '>default</span> <span style='color:#808030; '>NULL</span><span style='color:#800080; '>,</span>
  <span style='color:#800000; '>`</span><span >cStatus</span><span style='color:#800000; '>`</span> <span style='color:#bb7977; '>char</span><span style='color:#808030; '>(</span><span style='color:#008c00; '>1</span><span style='color:#808030; '>)</span> <span style='color:#074726; '>default</span> <span style='color:#808030; '>NULL</span><span style='color:#800080; '>,</span>
  <span style='color:#800000; font-weight:bold; '>PRIMARY</span> <span style='color:#800000; font-weight:bold; '>KEY</span>  <span style='color:#808030; '>(</span><span style='color:#800000; '>`</span><span >id</span><span style='color:#800000; '>`</span><span style='color:#808030; '>)</span><span style='color:#800080; '>,</span>
  <span style='color:#800000; font-weight:bold; '>UNIQUE</span> <span style='color:#800000; font-weight:bold; '>KEY</span> <span style='color:#800000; '>`</span><span >sUserID</span><span style='color:#800000; '>`</span> <span style='color:#808030; '>(</span><span style='color:#800000; '>`</span><span >sUserID</span><span style='color:#800000; '>`</span><span style='color:#808030; '>)</span><span style='color:#800080; '>,</span>
  <span style='color:#800000; font-weight:bold; '>UNIQUE</span> <span style='color:#800000; font-weight:bold; '>KEY</span> <span style='color:#800000; '>`</span><span >sEmail</span><span style='color:#800000; '>`</span> <span style='color:#808030; '>(</span><span style='color:#800000; '>`</span><span >sEmail</span><span style='color:#800000; '>`</span><span style='color:#808030; '>)</span>
<span style='color:#808030; '>)</span>
</pre>
</div>
<p><strong>2. Deploy project in tomcat or jBoss</strong></p>
<p><strong>3. Run application in browser</strong></p>
<p>4. Do Login by <strong>username admin</strong> and <strong>password admin</strong></p>
<p><a href="http://www.easywayserver.com/sourcecode/loginapplication.zip"><strong>Download login application</strong></a></p>
<div id="crp_related"><h3>Related Posts:</h3><ul style="list-style:disc;padding-left:20px"><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/building-a-user-registration-application/" rel="bookmark" class="crp_title">Building a User Registration Application</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts-iterator-database-fetching-example/" rel="bookmark" class="crp_title">Struts iterator database fetching example</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/upload-file-in-struts/" rel="bookmark" class="crp_title">Upload file in struts</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts-dynaform-validation/" rel="bookmark" class="crp_title">Struts &#8211; DynaForm validation</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts2-validation-example-struts-2-validation/" rel="bookmark" class="crp_title">Struts2 &#8211; Validation Example, Struts 2 Validation</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts2-example-struts2-tutorials-struts-program/" rel="bookmark" class="crp_title">Struts2 Example, Struts2 Tutorials, Struts Program</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.easywayserver.com/blog/building-a-login-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Handling and stop Duplicate Form Submissions in Struts</title>
		<link>http://www.easywayserver.com/blog/handling-and-stop-duplicate-form-submissions-in-struts/</link>
		<comments>http://www.easywayserver.com/blog/handling-and-stop-duplicate-form-submissions-in-struts/#comments</comments>
		<pubDate>Sat, 16 Oct 2010 07:39:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Struts]]></category>
		<category><![CDATA[struts examples]]></category>

		<guid isPermaLink="false">http://www.easywayserver.com/blog/?p=587</guid>
		<description><![CDATA[Duplicate form submission results in saving duplicate data in database unnecessary. If you don’t want to save duplicate data in database, you need to prevent duplicate request to save in database. Action form get old request and save request object again in html form, and if user reload the page, it will save again and [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.easywayserver.com%2Fblog%2Fhandling-and-stop-duplicate-form-submissions-in-struts%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.easywayserver.com%2Fblog%2Fhandling-and-stop-duplicate-form-submissions-in-struts%2F" height="61" width="51" /></a></div><p>Duplicate form submission results in saving duplicate data in database unnecessary. If you don’t want to save duplicate data in database, you need to prevent duplicate request to save in database. Action form get old request and save request object again in html form, and if user reload the page, it will save again and again in database.</p>
<p>Duplicate submission can be occur by refresh of page by user, pressing back button in browser, virus in user machine which resubmit form on every request.</p>
<p>Way to prevent duplicate request in Struts.</p>
<p>&nbsp;1. By handling isTokenValid() method of struts.</p>
<p>&nbsp;2. By handling clearing request object.</p>
<p>We are talking about clearing request object and creating new request for form.</p>
<div class="cde">
<pre><span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>action</span>
      <span style='color:#274796; '>input</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>input</span><span style='color:#0000e6; '>&quot;</span>
      <span style='color:#274796; '>path</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>/user_path</span><span style='color:#0000e6; '>&quot;</span>
      <span style='color:#274796; '>type</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>com.test.action.UserAction</span><span style='color:#0000e6; '>&quot;</span>
      <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>UserFormName</span><span style='color:#0000e6; '>&quot;</span>
      <span style='color:#274796; '>scope</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>request</span><span style='color:#0000e6; '>&quot;</span>
      <span style='color:#274796; '>validate</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>true</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
      <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>forward</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>failure</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>path</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>/home.jsp</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#a65700; '>/></span>
      <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>forward</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>input</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>path</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>/home.jsp</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#a65700; '>/></span>
      <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>forward</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>success</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>path</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;/home.jsp&quot;</span> <span style='color:#990000;'><strong>redirect</strong></span><span style='color:#990000;'><strong>=&quot;true&quot;</strong></span> <span style='color:#a65700; '>/></span>
<span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>action</span><span style='color:#a65700; '>></span>
</pre>
</div>
<p>Use redirect true attribute when form is saved successfully in database. This will generate new request and clear previous object for that form.</p>
<p>If you reload page with right click option, you will find your page’s data is not saving in database, and duplicate submits is stopped in struts by simply adding a <strong>redirect</strong> attribute</p>
<div id="crp_related"><h3>Related Posts:</h3><ul style="list-style:disc;padding-left:20px"><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/upload-file-in-struts/" rel="bookmark" class="crp_title">Upload file in struts</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts-iterator-database-fetching-example/" rel="bookmark" class="crp_title">Struts iterator database fetching example</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts-dynaform-validation/" rel="bookmark" class="crp_title">Struts &#8211; DynaForm validation</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/more-than-one-form-in-html-page/" rel="bookmark" class="crp_title">More than one form in HTML page</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/jsp-%e2%80%93-fetching-value-of-radio-button/" rel="bookmark" class="crp_title">JSP – Fetching Value of Radio Button</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/confirm-javascript/" rel="bookmark" class="crp_title">Confirm Javascript</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.easywayserver.com/blog/handling-and-stop-duplicate-form-submissions-in-struts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Struts iterator database fetching example</title>
		<link>http://www.easywayserver.com/blog/struts-iterator-database-fetching-example/</link>
		<comments>http://www.easywayserver.com/blog/struts-iterator-database-fetching-example/#comments</comments>
		<pubDate>Sun, 14 Mar 2010 06:55:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Struts]]></category>

		<guid isPermaLink="false">http://www.easywayserver.com/blog/?p=526</guid>
		<description><![CDATA[Struts Iterator database fetching Example 
In this struts example, we have to fetch and retrieve records from database and show on JSP page and submit to action class. 
Struts tutorials will explain how to use struts in logic Iterator tag in JSP to get data from database.
1. index.jsp

&#60;%@ page language=&#34;java&#34; pageEncoding=&#34;ISO-8859-1&#34;%>
&#60;%@ taglib uri=&#34;http://struts.apache.org/tags-bean&#34; prefix=&#34;bean&#34; %>
&#60;%@ [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.easywayserver.com%2Fblog%2Fstruts-iterator-database-fetching-example%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.easywayserver.com%2Fblog%2Fstruts-iterator-database-fetching-example%2F" height="61" width="51" /></a></div><p><strong>Struts Iterator database fetching Example</strong> </p>
<p>In this struts example, we have to fetch and retrieve records from database and show on JSP page and submit to action class. </p>
<p>Struts tutorials will explain how to use struts in logic Iterator tag in JSP to get data from database.</p>
<p>1. <strong>index.jsp</strong></p>
<div class="cde cdesize">
<pre><span style='color:#a65700;'>&lt;%@</span><span style='color:#000000;'> page language=</span><span style='color:#0000e6;'>&quot;java&quot;</span><span style='color:#000000;'> pageEncoding=</span><span style='color:#0000e6;'>&quot;ISO-8859-1&quot;</span><span style='color:#a65700;'>%></span>
<span style='color:#a65700;'>&lt;%@</span><span style='color:#000000;'> taglib uri=</span><span style='color:#0000e6;'>&quot;</span><span style='color:#5555dd;'>http://struts.apache.org/tags-bean</span><span style='color:#0000e6;'>&quot;</span><span style='color:#000000;'> prefix=</span><span style='color:#0000e6;'>&quot;bean&quot;</span><span style='color:#000000;'> </span><span style='color:#a65700;'>%></span>
<span style='color:#a65700;'>&lt;%@</span><span style='color:#000000;'> taglib uri=</span><span style='color:#0000e6;'>&quot;</span><span style='color:#5555dd;'>http://struts.apache.org/tags-html</span><span style='color:#0000e6;'>&quot;</span><span style='color:#000000;'> prefix=</span><span style='color:#0000e6;'>&quot;html&quot;</span><span style='color:#000000;'> </span><span style='color:#a65700;'>%></span>
<span style='color:#a65700;'>&lt;%@</span><span style='color:#000000;'> taglib uri=</span><span style='color:#0000e6;'>&quot;</span><span style='color:#5555dd;'>http://struts.apache.org/tags-logic</span><span style='color:#0000e6;'>&quot;</span><span style='color:#000000;'> prefix=</span><span style='color:#0000e6;'>&quot;logic&quot;</span><span style='color:#000000;'> </span><span style='color:#a65700;'>%></span>
<span style='color:#a65700;'>&lt;%@</span><span style='color:#000000;'> taglib uri=</span><span style='color:#0000e6;'>&quot;</span><span style='color:#5555dd;'>http://struts.apache.org/tags-tiles</span><span style='color:#0000e6;'>&quot;</span><span style='color:#000000;'> prefix=</span><span style='color:#0000e6;'>&quot;tiles&quot;</span><span style='color:#000000;'> </span><span style='color:#a65700;'>%></span>

<span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#5f5035; '>:</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#a65700; '>></span>
  <span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>head</span><span style='color:#a65700; '>></span>
    <span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>title</span><span style='color:#a65700; '>></span>Struts<span style='color:#008c00; '>.</span>jsp<span style='color:#a65700; '>&lt;/</span><span style='color:#800000; font-weight:bold; '>title</span><span style='color:#a65700; '>></span>
  <span style='color:#a65700; '>&lt;/</span><span style='color:#800000; font-weight:bold; '>head</span><span style='color:#a65700; '>></span>

  <span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>body</span><span style='color:#a65700; '>></span>
  <span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#5f5035; '>:</span><span style='color:#800000; font-weight:bold; '>form</span><span style='color:#274796; '> </span><span style='color:#074726; '>action</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;/searchUser&quot;</span><span style='color:#a65700; '>></span>

   <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>logic:iterate</span><span style='color:#274796; '> </span><span style='color:#074726; '>id</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;loop&quot;</span><span style='color:#274796; '>  </span><span style='color:#074726; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;UserForm&quot;</span><span style='color:#274796; '> property</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;ListUser&quot;</span><span style='color:#274796; '> </span><span style='color:#a65700; '>></span>
       <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>bean:write</span><span style='color:#274796; '> </span><span style='color:#074726; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;loop&quot;</span><span style='color:#274796; '> property</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;userName&quot;</span><span style='color:#a65700; '>/></span><span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>br</span><span style='color:#a65700; '>></span>
       <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>bean:write</span><span style='color:#274796; '> </span><span style='color:#074726; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;loop&quot;</span><span style='color:#274796; '> property</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;deptName&quot;</span><span style='color:#a65700; '>/></span><span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>br</span><span style='color:#a65700; '>></span><span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>br</span><span style='color:#a65700; '>></span>
   <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>logic:iterate</span><span style='color:#a65700; '>></span>

   <span style='color:#a65700; '>&lt;/</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#5f5035; '>:</span><span style='color:#800000; font-weight:bold; '>form</span><span style='color:#a65700; '>></span>
  <span style='color:#a65700; '>&lt;/</span><span style='color:#800000; font-weight:bold; '>body</span><span style='color:#a65700; '>></span>
<span style='color:#a65700; '>&lt;/</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#5f5035; '>:</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#a65700; '>></span>
</pre>
</div>
<p>2. <strong>struts-config.xml</strong></p>
<div class="cde cdesize">
<pre><span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>form-beans</span><span style='color:#a65700; '>></span>
     <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>form-bean</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>UserForm</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>type</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>org.apache.struts.validator.DynaValidatorForm</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
         <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>form-property</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>userId</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>type</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>java.lang.Integer</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#a65700; '>/></span>
         <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>form-property</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>userName</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>type</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>java.lang.String</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#a65700; '>/></span>
         <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>form-property</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>deptName</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>type</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>java.lang.String</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#a65700; '>/></span>
         <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>form-property</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>ListUser</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>type</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>java.util.ArrayList</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#a65700; '>/></span>
    <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>form-bean</span><span style='color:#a65700; '>></span>
  <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>form-beans</span><span style='color:#a65700; '>></span>

  <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>action-mappings</span><span style='color:#a65700; '>></span>
        <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>action</span>
            <span style='color:#274796; '>path</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>/searchUser</span><span style='color:#0000e6; '>&quot;</span>
            <span style='color:#274796; '>type</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>com.UserSearchAction</span><span style='color:#0000e6; '>&quot;</span>
            <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>UserForm</span><span style='color:#0000e6; '>&quot;</span>
            <span style='color:#274796; '>scope</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>request</span><span style='color:#0000e6; '>&quot;</span>
            <span style='color:#274796; '>validate</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>false</span><span style='color:#0000e6; '>&quot;</span>
            <span style='color:#274796; '>input</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>/index.jsp</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
            <span style='color:#a65700; '>&lt;</span><span style='color:#5f5035; '>forward</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>success</span><span style='color:#0000e6; '>&quot;</span> <span style='color:#274796; '>path</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>/index.jsp</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>/></span>
           <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>action</span><span style='color:#a65700; '>></span>
  <span style='color:#a65700; '>&lt;/</span><span style='color:#5f5035; '>action-mappings</span><span style='color:#a65700; '>></span>
</pre>
</div>
<p>3. <strong>UserSearchAction.java</strong></p>
<div class="cde cdesize">
<pre><span style='color:#800000; font-weight:bold; '>package</span><span style='color:#004a43; '> com</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> java</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>util</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>ArrayList</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> javax</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>servlet</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>http</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>HttpServletRequest</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> javax</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>servlet</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>http</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>HttpServletResponse</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> org</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>apache</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>struts</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>action</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>Action</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> org</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>apache</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>struts</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>action</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>ActionForm</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> org</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>apache</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>struts</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>action</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>ActionForward</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> org</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>apache</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>struts</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>action</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>ActionMapping</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> org</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>apache</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>struts</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>action</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>DynaActionForm</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>class</span> UserSearchAction <span style='color:#800000; font-weight:bold; '>extends</span> Action<span style='color:#800080; '>{</span>

     <span style='color:#800000; font-weight:bold; '>public</span> ActionForward execute<span style='color:#808030; '>(</span>
            ActionMapping mapping<span style='color:#808030; '>,</span>
            ActionForm form<span style='color:#808030; '>,</span>
            HttpServletRequest request<span style='color:#808030; '>,</span>
            HttpServletResponse response<span style='color:#808030; '>)</span> <span style='color:#800000; font-weight:bold; '>throws</span> <span style='color:#bb7977; font-weight:bold; '>Exception</span><span style='color:#800080; '>{</span>

         DynaActionForm userForm <span style='color:#808030; '>=</span> <span style='color:#808030; '>(</span>DynaActionForm<span style='color:#808030; '>)</span>form<span style='color:#800080; '>;</span>

         UserList ul<span style='color:#808030; '>=</span><span style='color:#800000; font-weight:bold; '>new</span> UserList<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
         ArrayList ar<span style='color:#808030; '>=</span><span style='color:#800000; font-weight:bold; '>new</span> ArrayList<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
         ar<span style='color:#808030; '>=</span>ul<span style='color:#808030; '>.</span>getUser<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

         userForm<span style='color:#808030; '>.</span>set<span style='color:#808030; '>(</span><span style='color:#0000e6; '>&quot;ListUser&quot;</span><span style='color:#808030; '>,</span> ar<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

         <span style='color:#800000; font-weight:bold; '>return</span> mapping<span style='color:#808030; '>.</span>findForward<span style='color:#808030; '>(</span><span style='color:#0000e6; '>&quot;success&quot;</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
     <span style='color:#800080; '>}</span>
<span style='color:#800080; '>}</span>
</pre>
</div>
<p>4. <strong>UserList.java</strong></p>
<div class="cde cdesize">
<pre><span style='color:#800000; font-weight:bold; '>package</span><span style='color:#004a43; '> com</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> java</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>util</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>ArrayList</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>class</span> UserList <span style='color:#800000; font-weight:bold; '>extends</span> User<span style='color:#800080; '>{</span>
     <span style='color:#800000; font-weight:bold; '>public</span> ArrayList getUser<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span>
     <span style='color:#800080; '>{</span>
        ArrayList<span style='color:#808030; '>&lt;</span>UserList<span style='color:#808030; '>></span> ar<span style='color:#808030; '>=</span><span style='color:#800000; font-weight:bold; '>new</span> ArrayList<span style='color:#808030; '>&lt;</span>UserList<span style='color:#808030; '>></span><span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> 

        UserList ul<span style='color:#800080; '>;</span>

        <span style='color:#800000; font-weight:bold; '>for</span><span style='color:#808030; '>(</span><span style='color:#bb7977; '>int</span> i<span style='color:#808030; '>=</span><span style='color:#008c00; '>0</span><span style='color:#800080; '>;</span>i<span style='color:#808030; '>&lt;</span><span style='color:#808030; '>=</span><span style='color:#008c00; '>20</span><span style='color:#800080; '>;</span>i<span style='color:#808030; '>+</span><span style='color:#808030; '>+</span><span style='color:#808030; '>)</span>
        <span style='color:#800080; '>{</span>
            ul<span style='color:#808030; '>=</span><span style='color:#800000; font-weight:bold; '>new</span> UserList<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            ul<span style='color:#808030; '>.</span>setUserId<span style='color:#808030; '>(</span>i<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            ul<span style='color:#808030; '>.</span>setUserName<span style='color:#808030; '>(</span><span style='color:#0000e6; '>&quot;userName&quot;</span><span style='color:#808030; '>+</span>i<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            ul<span style='color:#808030; '>.</span>setDeptName<span style='color:#808030; '>(</span><span style='color:#0000e6; '>&quot;Dept&quot;</span><span style='color:#808030; '>+</span>i<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            ar<span style='color:#808030; '>.</span>add<span style='color:#808030; '>(</span>ul<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#800080; '>}</span>
        <span style='color:#800000; font-weight:bold; '>return</span> ar<span style='color:#800080; '>;</span>
     <span style='color:#800080; '>}</span>
<span style='color:#800080; '>}</span>
</pre>
</div>
<p>5. <strong>User.java</strong></p>
<div class="cde cdesize">
<pre><span style='color:#800000; font-weight:bold; '>package</span><span style='color:#004a43; '> com</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>class</span> User <span style='color:#800080; '>{</span>
  <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; '>int</span> userId<span style='color:#800080; '>;</span>
  <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> userName<span style='color:#800080; '>;</span>
  <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> deptName<span style='color:#800080; '>;</span>

    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getDeptName<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> deptName<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setDeptName<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> deptName<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>deptName <span style='color:#808030; '>=</span> deptName<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>int</span> getUserId<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> userId<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setUserId<span style='color:#808030; '>(</span><span style='color:#bb7977; '>int</span> userId<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>userId <span style='color:#808030; '>=</span> userId<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getUserName<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> userName<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setUserName<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> userName<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>userName <span style='color:#808030; '>=</span> userName<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
<span style='color:#800080; '>}</span>
</pre>
</div>
<p>&nbsp;</p>
<p>Run this on web browser <b>http://localhost:8080/struts/searchUser.do</b></p>
<p><a href="http://www.easywayserver.com/sourcecode/strutsiterator.zip">download source code of struts Iterator</a></p>
<div id="crp_related"><h3>Related Posts:</h3><ul style="list-style:disc;padding-left:20px"><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts-dynaform-validation/" rel="bookmark" class="crp_title">Struts &#8211; DynaForm validation</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/upload-file-in-struts/" rel="bookmark" class="crp_title">Upload file in struts</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts2-validation-example-struts-2-validation/" rel="bookmark" class="crp_title">Struts2 &#8211; Validation Example, Struts 2 Validation</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/java-read-xml-taglib-and-jstl-in-jsp/" rel="bookmark" class="crp_title">JAVA &#8211; Read XML Taglib and JSTL in JSP</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts2-example-struts2-tutorials-struts-program/" rel="bookmark" class="crp_title">Struts2 Example, Struts2 Tutorials, Struts Program</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/handling-and-stop-duplicate-form-submissions-in-struts/" rel="bookmark" class="crp_title">Handling and stop Duplicate Form Submissions in Struts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.easywayserver.com/blog/struts-iterator-database-fetching-example/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Struts2 &#8211; Submit tag example</title>
		<link>http://www.easywayserver.com/blog/struts2-submit-tag-example/</link>
		<comments>http://www.easywayserver.com/blog/struts2-submit-tag-example/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 07:04:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Struts]]></category>
		<category><![CDATA[struts2]]></category>

		<guid isPermaLink="false">http://www.easywayserver.com/blog/?p=524</guid>
		<description><![CDATA[Submit tag struts 2 example 
Submit tag is used to Submit form to server with input form values, send data to server.
Example will show you how to use Submit tag in struts2

&#60;s:submit key=&#34;Submit&#34; />



Related Posts:JavaScript – Submit is not a functionHow to Submit a Form Using JavaScriptStruts2 &#8211; Input text tag exampleMore than one form [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.easywayserver.com%2Fblog%2Fstruts2-submit-tag-example%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.easywayserver.com%2Fblog%2Fstruts2-submit-tag-example%2F" height="61" width="51" /></a></div><p><strong>Submit tag struts 2 example</strong> <br />
Submit tag is used to Submit form to server with input form values, send data to server.</p>
<p>Example will show you how to use Submit tag in struts2</p>
<div class="cde cdesize">
<pre><span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>s</span><span style='color:#5f5035; '>:</span><span style='color:#800000; font-weight:bold; '>submit</span><span style='color:#274796; '> key</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;Submit&quot;</span><span style='color:#274796; '> </span><span style='color:#a65700; '>/></span>
</pre>
</div>
<p><img src="http://www.easywayserver.com/images/struts2/submit.jpg"  border="0"/></p>
<div id="crp_related"><h3>Related Posts:</h3><ul style="list-style:disc;padding-left:20px"><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/javascript-%e2%80%93-submit-is-not-a-function/" rel="bookmark" class="crp_title">JavaScript – Submit is not a function</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/how-to-submit-a-form-using-javascript/" rel="bookmark" class="crp_title">How to Submit a Form Using JavaScript</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts2-input-text-tag-example/" rel="bookmark" class="crp_title">Struts2 &#8211; Input text tag example</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/more-than-one-form-in-html-page/" rel="bookmark" class="crp_title">More than one form in HTML page</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts2-password-input-tag-example/" rel="bookmark" class="crp_title">Struts2 &#8211; Password input tag example</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts2-textarea-tag-example/" rel="bookmark" class="crp_title">Struts2 &#8211; textarea tag example</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.easywayserver.com/blog/struts2-submit-tag-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Struts2 &#8211; Password input tag example</title>
		<link>http://www.easywayserver.com/blog/struts2-password-input-tag-example/</link>
		<comments>http://www.easywayserver.com/blog/struts2-password-input-tag-example/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 06:52:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Struts]]></category>
		<category><![CDATA[struts2]]></category>

		<guid isPermaLink="false">http://www.easywayserver.com/blog/?p=522</guid>
		<description><![CDATA[Password tag struts 2 example 
Password tag is used to get password input from user, send data to server. Struts2 Password tag can get hidden character input data from user in browser.
Example will show you how to use Password tag in struts2

&#60;s:password key=&#34;txtpwd&#34; />



Related Posts:Struts2 &#8211; Input text tag examplePassword Field in HTMLStruts2 &#8211; textarea [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.easywayserver.com%2Fblog%2Fstruts2-password-input-tag-example%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.easywayserver.com%2Fblog%2Fstruts2-password-input-tag-example%2F" height="61" width="51" /></a></div><p><strong>Password tag struts 2 example</strong> <br />
Password tag is used to get password input from user, send data to server. Struts2 Password tag can get hidden character input data from user in browser.</p>
<p>Example will show you how to use Password tag in struts2</p>
<div class="cde cdesize">
<pre><span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>s</span><span style='color:#5f5035; '>:</span><span style='color:#800000; font-weight:bold; '>password</span><span style='color:#274796; '> key</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;txtpwd&quot;</span><span style='color:#274796; '> </span><span style='color:#a65700; '>/></span>
</pre>
</div>
<p><img src="http://www.easywayserver.com/images/struts2/password.jpg"  border="0"/></p>
<div id="crp_related"><h3>Related Posts:</h3><ul style="list-style:disc;padding-left:20px"><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts2-input-text-tag-example/" rel="bookmark" class="crp_title">Struts2 &#8211; Input text tag example</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/password-field-in-html/" rel="bookmark" class="crp_title">Password Field in HTML</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts2-textarea-tag-example/" rel="bookmark" class="crp_title">Struts2 &#8211; textarea tag example</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts2-validation-example-struts-2-validation/" rel="bookmark" class="crp_title">Struts2 &#8211; Validation Example, Struts 2 Validation</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts2-submit-tag-example/" rel="bookmark" class="crp_title">Struts2 &#8211; Submit tag example</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts2-file-tag-example/" rel="bookmark" class="crp_title">Struts2 &#8211; File tag example</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.easywayserver.com/blog/struts2-password-input-tag-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Struts2 &#8211; textarea tag example</title>
		<link>http://www.easywayserver.com/blog/struts2-textarea-tag-example/</link>
		<comments>http://www.easywayserver.com/blog/struts2-textarea-tag-example/#comments</comments>
		<pubDate>Sun, 03 Jan 2010 14:38:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Struts]]></category>
		<category><![CDATA[struts2]]></category>

		<guid isPermaLink="false">http://www.easywayserver.com/blog/?p=520</guid>
		<description><![CDATA[Textarea tag struts 2 example 
Textarea tag is used to get input from user, send data to server. Struts2 textarea tag can get more input data from user in browser.
Example will show you how to use textarea tag in struts2

&#60;s:textarea key=&#34;txtArea&#34; value=&#34;value&#34; cols=&#34;50&#34; rows=&#34;5&#34; />



Related Posts:Struts2 &#8211; Input text tag exampleStruts2 &#8211; Password input tag [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.easywayserver.com%2Fblog%2Fstruts2-textarea-tag-example%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.easywayserver.com%2Fblog%2Fstruts2-textarea-tag-example%2F" height="61" width="51" /></a></div><p><strong>Textarea tag struts 2 example</strong> <br />
Textarea tag is used to get input from user, send data to server. Struts2 textarea tag can get more input data from user in browser.</p>
<p>Example will show you how to use textarea tag in struts2</p>
<div class="cde cdesize">
<pre><span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>s</span><span style='color:#5f5035; '>:</span><span style='color:#800000; font-weight:bold; '>textarea</span><span style='color:#274796; '> key</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;txtArea&quot;</span><span style='color:#274796; '> </span><span style='color:#074726; '>value</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;value&quot;</span><span style='color:#274796; '> </span><span style='color:#074726; '>cols</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;50&quot;</span><span style='color:#274796; '> </span><span style='color:#074726; '>rows</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;5&quot;</span><span style='color:#274796; '> </span><span style='color:#a65700; '>/></span>
</pre>
</div>
<p><img src="http://www.easywayserver.com/images/struts2/textarea.jpg"  border="0"/></p>
<div id="crp_related"><h3>Related Posts:</h3><ul style="list-style:disc;padding-left:20px"><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts2-input-text-tag-example/" rel="bookmark" class="crp_title">Struts2 &#8211; Input text tag example</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts2-password-input-tag-example/" rel="bookmark" class="crp_title">Struts2 &#8211; Password input tag example</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts2-file-tag-example/" rel="bookmark" class="crp_title">Struts2 &#8211; File tag example</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts2-submit-tag-example/" rel="bookmark" class="crp_title">Struts2 &#8211; Submit tag example</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/javascript-innerhtml/" rel="bookmark" class="crp_title">JavaScript innerHTML</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts2-checkbox-tag-example-check-box-example/" rel="bookmark" class="crp_title">Struts2 &#8211; checkbox tag example, check box example</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.easywayserver.com/blog/struts2-textarea-tag-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Struts2 &#8211; Input text tag example</title>
		<link>http://www.easywayserver.com/blog/struts2-input-text-tag-example/</link>
		<comments>http://www.easywayserver.com/blog/struts2-input-text-tag-example/#comments</comments>
		<pubDate>Sun, 03 Jan 2010 11:50:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Struts]]></category>
		<category><![CDATA[struts2]]></category>

		<guid isPermaLink="false">http://www.easywayserver.com/blog/?p=517</guid>
		<description><![CDATA[Input text tag struts 2 example Input text tag is used to get input from user, send data to server.
Example will show you how to use Input text tag in struts2

&#60;s:textfield key=&#34;username&#34; />



Related Posts:Struts2 &#8211; Password input tag exampleStruts2 &#8211; textarea tag exampleStruts2 &#8211; Submit tag exampleStruts2 &#8211; File tag exampleStruts2 &#8211; Select box tag [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.easywayserver.com%2Fblog%2Fstruts2-input-text-tag-example%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.easywayserver.com%2Fblog%2Fstruts2-input-text-tag-example%2F" height="61" width="51" /></a></div><p><strong>Input text tag struts 2 example</strong> <br />Input text tag is used to get input from user, send data to server.</p>
<p>Example will show you how to use Input text tag in struts2</p>
<div class="cde cdesize">
<pre><span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>s</span><span style='color:#5f5035; '>:textfield</span><span style='color:#274796; '> </span><span style='color:#074726; '>key</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;username&quot;</span><span style='color:#274796; '> </span><span style='color:#a65700; '>/></span>
</pre>
</div>
<p><img src="http://www.easywayserver.com/images/struts2/inputtag.jpg"  border="0"/></p>
<div id="crp_related"><h3>Related Posts:</h3><ul style="list-style:disc;padding-left:20px"><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts2-password-input-tag-example/" rel="bookmark" class="crp_title">Struts2 &#8211; Password input tag example</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts2-textarea-tag-example/" rel="bookmark" class="crp_title">Struts2 &#8211; textarea tag example</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts2-submit-tag-example/" rel="bookmark" class="crp_title">Struts2 &#8211; Submit tag example</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts2-file-tag-example/" rel="bookmark" class="crp_title">Struts2 &#8211; File tag example</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts2-select-box-tag-example/" rel="bookmark" class="crp_title">Struts2 &#8211; Select box tag example</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts2-validation-example-struts-2-validation/" rel="bookmark" class="crp_title">Struts2 &#8211; Validation Example, Struts 2 Validation</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.easywayserver.com/blog/struts2-input-text-tag-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Struts2 &#8211; Validation Example, Struts 2 Validation</title>
		<link>http://www.easywayserver.com/blog/struts2-validation-example-struts-2-validation/</link>
		<comments>http://www.easywayserver.com/blog/struts2-validation-example-struts-2-validation/#comments</comments>
		<pubDate>Sun, 27 Dec 2009 10:02:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Struts]]></category>
		<category><![CDATA[struts2]]></category>

		<guid isPermaLink="false">http://www.easywayserver.com/blog/?p=515</guid>
		<description><![CDATA[Struts2 Validation Example Struts2 validation implement by xml file in struts 2. Validation is more easier to implement in struts2. We can define our rules of validation in xml file and use in jsp field. Struts2 provides more options of validation like email validation, integer range validation, form validation field, expression validation, regex validation, required [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.easywayserver.com%2Fblog%2Fstruts2-validation-example-struts-2-validation%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.easywayserver.com%2Fblog%2Fstruts2-validation-example-struts-2-validation%2F" height="61" width="51" /></a></div><p><strong>Struts2 Validation Example</strong> <br />Struts2 validation implement by xml file in struts 2. Validation is more easier to implement in struts2. We can define our rules of validation in xml file and use in jsp field. Struts2 provides more options of validation like email validation, integer range validation, form validation field, expression validation, regex validation, required validation, requiredstring validation, stringlength validation and etc.</p>
<p>Register jsp struts 2 application form can be validated with number of options which are shown in example. </p>
<p>Example will explain how to use validation in struts 2.</p>
<p>1. <strong>register.jsp</strong> registration form jsp</p>
<div class="cde cdesize">
<pre><span style='color:#a65700;'>&lt;%@</span><span style='color:#000000;'> page contentType=</span><span style='color:#0000e6;'>&quot;text/html; charset=UTF-8&quot;</span><span style='color:#000000;'> </span><span style='color:#a65700;'>%></span>
<span style='color:#a65700;'>&lt;%@</span><span style='color:#000000;'> taglib prefix=</span><span style='color:#0000e6;'>&quot;s&quot;</span><span style='color:#000000;'> uri=</span><span style='color:#0000e6;'>&quot;/struts-tags&quot;</span><span style='color:#000000;'> </span><span style='color:#a65700;'>%></span>
<span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#a65700; '>></span>
<span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>head</span><span style='color:#a65700; '>></span>
    <span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>title</span><span style='color:#a65700; '>></span>Validation Struts page<span style='color:#a65700; '>&lt;/</span><span style='color:#800000; font-weight:bold; '>title</span><span style='color:#a65700; '>></span>
    <span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>s</span><span style='color:#5f5035; '>:</span><span style='color:#800000; font-weight:bold; '>head</span><span style='color:#a65700; '>/></span>
<span style='color:#a65700; '>&lt;/</span><span style='color:#800000; font-weight:bold; '>head</span><span style='color:#a65700; '>></span>

<span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>body</span><span style='color:#a65700; '>></span>
<span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>s</span><span style='color:#5f5035; '>:</span><span style='color:#800000; font-weight:bold; '>form</span><span style='color:#274796; '> </span><span style='color:#074726; '>action</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;Register&quot;</span><span style='color:#a65700; '>></span>
    <span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>s</span><span style='color:#5f5035; '>:textfield</span><span style='color:#274796; '> key</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;username&quot;</span><span style='color:#a65700; '>/></span>
    <span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>s</span><span style='color:#5f5035; '>:password</span><span style='color:#274796; '> key</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;password&quot;</span><span style='color:#274796; '> </span><span style='color:#a65700; '>/></span>
    <span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>s</span><span style='color:#5f5035; '>:textfield</span><span style='color:#274796; '> key</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;email&quot;</span><span style='color:#274796; '> </span><span style='color:#a65700; '>/></span>
    <span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>s</span><span style='color:#5f5035; '>:</span><span style='color:#800000; font-weight:bold; '>select</span><span style='color:#274796; '> headerKey</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;&quot;</span><span style='color:#274796; '> headerValue</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;Select Gender&quot;</span><span style='color:#274796; '></span>
<span style='color:#274796; '>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;key</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;gender&quot;</span><span style='color:#274796; '> list</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;#{'M':'Male','F':'Female'}&quot;</span><span style='color:#274796; '> </span><span style='color:#a65700; '>/></span>
    <span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>s</span><span style='color:#5f5035; '>:textfield</span><span style='color:#274796; '> key</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;postalcode&quot;</span><span style='color:#274796; '> </span><span style='color:#a65700; '>/></span>
    <span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>s</span><span style='color:#5f5035; '>:submit</span><span style='color:#a65700; '>/></span>
<span style='color:#a65700; '>&lt;/</span><span style='color:#800000; font-weight:bold; '>s</span><span style='color:#5f5035; '>:</span><span style='color:#800000; font-weight:bold; '>form</span><span style='color:#a65700; '>></span>
<span style='color:#a65700; '>&lt;/</span><span style='color:#800000; font-weight:bold; '>body</span><span style='color:#a65700; '>></span>
<span style='color:#a65700; '>&lt;/</span><span style='color:#800000; font-weight:bold; '>html</span><span style='color:#a65700; '>></span>
</pre>
</div>
<p><img src="http://www.easywayserver.com/images/struts2/validation/register.jpg"  border="0"/></p>
<p>2. <strong>web.xml</strong></p>
<div class="cde cdesize">
<pre>
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;web-app id=&quot;WebApp_9&quot; version=&quot;2.4&quot; xmlns=&quot;http://java.sun.com/xml/ns/j2ee&quot;
   xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
   xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/j2ee
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd&quot;&gt;

    &lt;display-name&gt;Struts Blank&lt;/display-name&gt;

    &lt;filter&gt;
        &lt;filter-name&gt;struts2&lt;/filter-name&gt;
        &lt;filter-class&gt;org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter&lt;/filter-class&gt;
    &lt;/filter&gt;

    &lt;filter-mapping&gt;
        &lt;filter-name&gt;struts2&lt;/filter-name&gt;
        &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
    &lt;/filter-mapping&gt;

    &lt;welcome-file-list&gt;
        &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
    &lt;/welcome-file-list&gt;

&lt;/web-app&gt;
</pre>
</div>
<p>3. <strong>register.xml</strong></p>
<div class="cde cdesize">
<pre>
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;
&lt;!DOCTYPE struts PUBLIC
        &quot;-//Apache Software Foundation//DTD Struts Configuration 2.0//EN&quot;
        &quot;http://struts.apache.org/dtds/struts-2.0.dtd&quot;&gt;

&lt;struts&gt;

    &lt;package name=&quot;register&quot; namespace=&quot;/&quot; extends=&quot;struts-default&quot;&gt;

        &lt;action name=&quot;Register&quot; class=&quot;com.struts2.RegisterAction&quot;&gt;
            &lt;result name=&quot;input&quot;&gt;/register.jsp&lt;/result&gt;
            &lt;result type=&quot;redirectAction&quot;&gt;register.jsp&lt;/result&gt;
        &lt;/action&gt;

        &lt;!-- Add actions here --&gt;
    &lt;/package&gt;
&lt;/struts&gt;
</pre>
</div>
<p>4. <strong>struts.xml</strong></p>
<div class="cde cdesize">
<pre>
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;
&lt;!DOCTYPE struts PUBLIC
    &quot;-//Apache Software Foundation//DTD Struts Configuration 2.0//EN&quot;
    &quot;http://struts.apache.org/dtds/struts-2.0.dtd&quot;&gt;

&lt;struts&gt;

    &lt;constant name=&quot;struts.enable.DynamicMethodInvocation&quot; value=&quot;false&quot; /&gt;
    &lt;constant name=&quot;struts.devMode&quot; value=&quot;false&quot; /&gt;

    &lt;include file=&quot;register.xml&quot;/&gt;

    &lt;!-- Add packages here --&gt;

&lt;/struts&gt;
</pre>
</div>
<p>5. <strong>RegisterAction.java</strong></p>
<div class="cde cdesize">
<pre><span style='color:#800000; font-weight:bold; '>package</span><span style='color:#004a43; '> com</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>struts2</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>class</span> RegisterAction <span style='color:#800000; font-weight:bold; '>extends</span> MyRegisterSupport<span style='color:#800080; '>{</span>

    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#800000; font-weight:bold; '>static</span> <span style='color:#800000; font-weight:bold; '>final</span> <span style='color:#bb7977; '>long</span> serialVersionUID <span style='color:#808030; '>=</span> <span style='color:#008c00; '>1</span><span style='color:#006600; '>L</span><span style='color:#800080; '>;</span>

    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> execute<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800000; font-weight:bold; '>throws</span> <span style='color:#bb7977; font-weight:bold; '>Exception</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> SUCCESS<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
<span style='color:#800080; '>}</span>
</pre>
</div>
<p>6. <strong>MyRegisterSupport.java</strong></p>
<div class="cde cdesize">
<pre><span style='color:#800000; font-weight:bold; '>package</span><span style='color:#004a43; '> com</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>struts2</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> com</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>opensymphony</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>xwork2</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>ActionSupport</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>class</span> MyRegisterSupport <span style='color:#800000; font-weight:bold; '>extends</span> ActionSupport<span style='color:#800080; '>{</span>

    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#800000; font-weight:bold; '>static</span> <span style='color:#800000; font-weight:bold; '>final</span> <span style='color:#bb7977; '>long</span> serialVersionUID <span style='color:#808030; '>=</span> <span style='color:#008c00; '>1</span><span style='color:#006600; '>L</span><span style='color:#800080; '>;</span>

    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> username<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> password<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> email<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> gender<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>private</span> <span style='color:#bb7977; font-weight:bold; '>String</span> postalcode<span style='color:#800080; '>;</span>

    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getEmail<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> email<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setEmail<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> email<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>email <span style='color:#808030; '>=</span> email<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getGender<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> gender<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setGender<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> gender<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>gender <span style='color:#808030; '>=</span> gender<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>

    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getPassword<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> password<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setPassword<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> password<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>password <span style='color:#808030; '>=</span> password<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>

    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getPostalcode<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> postalcode<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setPostalcode<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> postalcode<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>postalcode <span style='color:#808030; '>=</span> postalcode<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>String</span> getUsername<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>return</span> username<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#bb7977; '>void</span> setUsername<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span> username<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>this</span><span style='color:#808030; '>.</span>username <span style='color:#808030; '>=</span> username<span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
<span style='color:#800080; '>}</span>
</pre>
</div>
<p>7. <strong>RegisterAction-validation.xml</strong></p>
<div class="cde cdesize">
<pre><span style='color:#004a43; '>&lt;!</span><span style='color:#004a43; '>DOCTYPE</span> <span style='color:#004a43; '>validators</span> <span style='color:#800000; font-weight:bold; '>PUBLIC</span>
        <span style='color:#0000e6; '>&quot;-//OpenSymphony Group//XWork Validator 1.0.2//EN&quot;</span>
        <span style='color:#0000e6; '>&quot;http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd&quot;</span><span style='color:#004a43; '>></span>

<span style='color:#a65700; '>&lt;</span><span style='color:#3F7F7F; '>validators</span><span style='color:#a65700; '>></span>
    <span style='color:#a65700; '>&lt;</span><span style='color:#3F7F7F; '>field</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>username</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
        <span style='color:#a65700; '>&lt;</span><span style='color:#3F7F7F; '>field-validator</span> <span style='color:#274796; '>type</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>requiredstring</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
            <span style='color:#a65700; '>&lt;</span><span style='color:#3F7F7F; '>message</span> <span style='color:#274796; '>key</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>requiredstring</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>/></span>
        <span style='color:#a65700; '>&lt;/</span><span style='color:#3F7F7F; '>field-validator</span><span style='color:#a65700; '>></span>
    <span style='color:#a65700; '>&lt;/</span><span style='color:#3F7F7F; '>field</span><span style='color:#a65700; '>></span>
    <span style='color:#a65700; '>&lt;</span><span style='color:#3F7F7F; '>field</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>password</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
        <span style='color:#a65700; '>&lt;</span><span style='color:#3F7F7F; '>field-validator</span> <span style='color:#274796; '>type</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>requiredstring</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
            <span style='color:#a65700; '>&lt;</span><span style='color:#3F7F7F; '>message</span> <span style='color:#274796; '>key</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>requiredstring</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>/></span>
        <span style='color:#a65700; '>&lt;/</span><span style='color:#3F7F7F; '>field-validator</span><span style='color:#a65700; '>></span>
        <span style='color:#a65700; '>&lt;</span><span style='color:#3F7F7F; '>field-validator</span> <span style='color:#274796; '>type</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>stringlength</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
            <span style='color:#a65700; '>&lt;</span><span style='color:#3F7F7F; '>param</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>minLength</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>6<span style='color:#a65700; '>&lt;/</span><span style='color:#3F7F7F; '>param</span><span style='color:#a65700; '>></span>
            <span style='color:#a65700; '>&lt;</span><span style='color:#3F7F7F; '>param</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>trim</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>true<span style='color:#a65700; '>&lt;/</span><span style='color:#3F7F7F; '>param</span><span style='color:#a65700; '>></span>
            <span style='color:#a65700; '>&lt;</span><span style='color:#3F7F7F; '>message</span> <span style='color:#274796; '>key</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>requiredpassword</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>/></span>
        <span style='color:#a65700; '>&lt;/</span><span style='color:#3F7F7F; '>field-validator</span><span style='color:#a65700; '>></span>
    <span style='color:#a65700; '>&lt;/</span><span style='color:#3F7F7F; '>field</span><span style='color:#a65700; '>></span>
    <span style='color:#a65700; '>&lt;</span><span style='color:#3F7F7F; '>field</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>email</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
        <span style='color:#a65700; '>&lt;</span><span style='color:#3F7F7F; '>field-validator</span> <span style='color:#274796; '>type</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>requiredstring</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
            <span style='color:#a65700; '>&lt;</span><span style='color:#3F7F7F; '>message</span> <span style='color:#274796; '>key</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>requiredstring</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>/></span>
        <span style='color:#a65700; '>&lt;/</span><span style='color:#3F7F7F; '>field-validator</span><span style='color:#a65700; '>></span>
        <span style='color:#a65700; '>&lt;</span><span style='color:#3F7F7F; '>field-validator</span> <span style='color:#274796; '>type</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>email</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
            <span style='color:#a65700; '>&lt;</span><span style='color:#3F7F7F; '>message</span> <span style='color:#274796; '>key</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>requiredemail</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>/></span>
        <span style='color:#a65700; '>&lt;/</span><span style='color:#3F7F7F; '>field-validator</span><span style='color:#a65700; '>></span>
    <span style='color:#a65700; '>&lt;/</span><span style='color:#3F7F7F; '>field</span><span style='color:#a65700; '>></span>
    <span style='color:#a65700; '>&lt;</span><span style='color:#3F7F7F; '>field</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>gender</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
        <span style='color:#a65700; '>&lt;</span><span style='color:#3F7F7F; '>field-validator</span> <span style='color:#274796; '>type</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>requiredstring</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
            <span style='color:#a65700; '>&lt;</span><span style='color:#3F7F7F; '>message</span> <span style='color:#274796; '>key</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>requiredstring</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>/></span>
        <span style='color:#a65700; '>&lt;/</span><span style='color:#3F7F7F; '>field-validator</span><span style='color:#a65700; '>></span>
    <span style='color:#a65700; '>&lt;/</span><span style='color:#3F7F7F; '>field</span><span style='color:#a65700; '>></span>
    <span style='color:#a65700; '>&lt;</span><span style='color:#3F7F7F; '>field</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>postalcode</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
        <span style='color:#a65700; '>&lt;</span><span style='color:#3F7F7F; '>field-validator</span> <span style='color:#274796; '>type</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>requiredstring</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
            <span style='color:#a65700; '>&lt;</span><span style='color:#3F7F7F; '>message</span> <span style='color:#274796; '>key</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>requiredstring</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>/></span>
        <span style='color:#a65700; '>&lt;/</span><span style='color:#3F7F7F; '>field-validator</span><span style='color:#a65700; '>></span>
        <span style='color:#a65700; '>&lt;</span><span style='color:#3F7F7F; '>field-validator</span> <span style='color:#274796; '>type</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>regex</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span>
            <span style='color:#a65700; '>&lt;</span><span style='color:#3F7F7F; '>param</span> <span style='color:#274796; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>expression</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>></span><span style='color:#606060; '>&lt;![CDATA[</span>^\d*$<span style='color:#606060; '>]]&gt;</span><span style='color:#a65700; '>&lt;/</span><span style='color:#3F7F7F; '>param</span><span style='color:#a65700; '>></span>
            <span style='color:#a65700; '>&lt;</span><span style='color:#3F7F7F; '>message</span> <span style='color:#274796; '>key</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;</span><span style='color:#0000e6; '>requiredinteger</span><span style='color:#0000e6; '>&quot;</span><span style='color:#a65700; '>/></span>
          <span style='color:#a65700; '>&lt;/</span><span style='color:#3F7F7F; '>field-validator</span><span style='color:#a65700; '>></span>
    <span style='color:#a65700; '>&lt;/</span><span style='color:#3F7F7F; '>field</span><span style='color:#a65700; '>></span>
<span style='color:#a65700; '>&lt;/</span><span style='color:#3F7F7F; '>validators</span><span style='color:#a65700; '>></span>
</pre>
</div>
<p>8. <strong>package.properties</strong></p>
<div class="cde cdesize">
<pre>
requiredstring = ${getText(fieldName)} is required.
requiredemail = ${getText(fieldName)} is not in correct format.
requiredpassword = ${getText(fieldName)} should be more than 6 character.
requiredinteger = ${getText(fieldName)} should be numeric.
password = Password
username = User Name
email = Email Address
gender = Gender
postalcode = Postal Code
</pre>
</div>
<p>Validation failed</p>
<p>empty field validation</p>
<p><img src="http://www.easywayserver.com/images/struts2/validation/validate.jpg"  border="0"/></p>
<p>Password field length check</p>
<p><img src="http://www.easywayserver.com/images/struts2/validation/password.jpg"  border="0"/></p>
<p>Integer field validation check struts2</p>
<p><img src="http://www.easywayserver.com/images/struts2/validation/integer.jpg"  border="0"/></p>
<p>Email field validation</p>
<p><img src="http://www.easywayserver.com/images/struts2/validation/email.jpg"  border="0"/></p>
<p><a href="http://www.easywayserver.com/sourcecode/struts2validate.zip">download source code of struts2 validation</a></p>
<div id="crp_related"><h3>Related Posts:</h3><ul style="list-style:disc;padding-left:20px"><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts2-example-struts2-tutorials-struts-program/" rel="bookmark" class="crp_title">Struts2 Example, Struts2 Tutorials, Struts Program</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts-dynaform-validation/" rel="bookmark" class="crp_title">Struts &#8211; DynaForm validation</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/password-field-in-html/" rel="bookmark" class="crp_title">Password Field in HTML</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts-iterator-database-fetching-example/" rel="bookmark" class="crp_title">Struts iterator database fetching example</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/java-read-xml-taglib-and-jstl-in-jsp/" rel="bookmark" class="crp_title">JAVA &#8211; Read XML Taglib and JSTL in JSP</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/more-than-one-form-in-html-page/" rel="bookmark" class="crp_title">More than one form in HTML page</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.easywayserver.com/blog/struts2-validation-example-struts-2-validation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Struts2 &#8211; File tag example</title>
		<link>http://www.easywayserver.com/blog/struts2-file-tag-example/</link>
		<comments>http://www.easywayserver.com/blog/struts2-file-tag-example/#comments</comments>
		<pubDate>Sat, 26 Dec 2009 08:25:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Struts]]></category>
		<category><![CDATA[struts2]]></category>

		<guid isPermaLink="false">http://www.easywayserver.com/blog/struts2-file-tag-example/</guid>
		<description><![CDATA[File tag struts 2 example File tag is used to upload file to server with browsing option.
Example will show you how to use file tag in struts2

&#60;s:file name=&#34;myFile&#34; />



Related Posts:Struts2 &#8211; Input text tag exampleStruts2 &#8211; checkbox tag example, check box exampleStruts2 &#8211; Submit tag exampleStruts2 &#8211; Password input tag exampleStruts2 &#8211; textarea tag exampleStruts2 [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.easywayserver.com%2Fblog%2Fstruts2-file-tag-example%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.easywayserver.com%2Fblog%2Fstruts2-file-tag-example%2F" height="61" width="51" /></a></div><p><strong>File tag struts 2 example</strong> <br />File tag is used to upload file to server with browsing option.</p>
<p>Example will show you how to use file tag in struts2</p>
<div class="cde cdesize">
<pre><span style='color:#a65700; '>&lt;</span><span style='color:#800000; font-weight:bold; '>s</span><span style='color:#5f5035; '>:file</span><span style='color:#274796; '> </span><span style='color:#074726; '>name</span><span style='color:#808030; '>=</span><span style='color:#0000e6; '>&quot;myFile&quot;</span><span style='color:#274796; '> </span><span style='color:#a65700; '>/></span>
</pre>
</div>
<p><img src="http://www.easywayserver.com/images/struts2/filetag.jpg"  border="0"/></p>
<div id="crp_related"><h3>Related Posts:</h3><ul style="list-style:disc;padding-left:20px"><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts2-input-text-tag-example/" rel="bookmark" class="crp_title">Struts2 &#8211; Input text tag example</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts2-checkbox-tag-example-check-box-example/" rel="bookmark" class="crp_title">Struts2 &#8211; checkbox tag example, check box example</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts2-submit-tag-example/" rel="bookmark" class="crp_title">Struts2 &#8211; Submit tag example</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts2-password-input-tag-example/" rel="bookmark" class="crp_title">Struts2 &#8211; Password input tag example</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts2-textarea-tag-example/" rel="bookmark" class="crp_title">Struts2 &#8211; textarea tag example</a></li><li style="padding-left:8px"><a href="http://www.easywayserver.com/blog/struts2-select-box-tag-example/" rel="bookmark" class="crp_title">Struts2 &#8211; Select box tag example</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.easywayserver.com/blog/struts2-file-tag-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

