Thursday, 1 August 2013

Struts+Maven+Ibatis ( Login Example )

1.Make a new Maven Project and configure Settings file in maven prospective:




2.Select Filter for WebApp:



 3: Got structured layout of project as shown below:



4:Add dependencies in POM.XML you needed:
<dependencies>
        <dependency>
            <groupId>struts</groupId>
            <artifactId>struts</artifactId>
            <version>1.2.9</version>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.1.3</version>
        </dependency>
        <dependency>
            <groupId>commons-digester</groupId>
            <artifactId>commons-digester</artifactId>
            <version>2.1</version>
        </dependency>
        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
            <version>1.8.3</version>
        </dependency>
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.6</version>
        </dependency>
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>3.2.1</version>
        </dependency>
        <dependency>
              <groupId>org.apache.struts</groupId>
              <artifactId>struts-taglib</artifactId>
             <version>1.3.10</version>
        </dependency>
        <dependency>
            <groupId>org.apache.ibatis</groupId>
            <artifactId>ibatis-sqlmap</artifactId>
            <version>2.3.4.726</version>
        </dependency>
        <dependency>
            <groupId>postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>8.3-603.jdbc3</version>
        </dependency>
 </dependencies>

5:Make a welcome page(index.jsp):
 <!DOCTYPE html>
<html>
<body>
<h2>Hello World!</h2>
<a href="login.jsp">Sign in</a>
</body>
</html>

6:Make Entry of welcome page in web.xml:
<welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
</welcome-file-list>

7:Make Simple login page(login.jsp) using struts taglib :
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %> 
<!DOCTYPE html>
<html>
<body>
<h2>Hello World!</h2>
<html:form action="/Login" >
    <html:errors />
    User Name :<html:text name="loginform" property="userName" /><br>
    Password  :<html:password name="loginform" property="password" /><br>
<html:submit value="Login" />
<html:reset value="Reset" />
</html:form>
</body>
</html>
 

1 comment: