Ex No - 11
Ex No - 11
2. Select Archetype:
Choose maven-archetype-quickstart or skip this step to create a simple project. Click Next.
Version: 1.0-SNAPSHOT
Click Finish.
<dependencies>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.5.20</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>javax.servlet.jsp.jstl-api</artifactId>
<version>1.2.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
3. Save the pom.xml file and right-click on your project, then select Maven > Update Project to
download the necessary dependencies.
Step 4: Create the Registration Form
Right-click on the project in Eclipse and select New > Folder. Name it src/main/webapp.
Right-click on the src/main/webapp folder, select New > File, and name it registration.jsp.
Program
<html>
<head>
<title>User Registration</title>
</head>
<body>
<h2>User Registration</h2>
</s:form>
</body>
</html>
Right-click on the com.example.action package, select New > Class, and name it RegistrationAction.
Program
package com.example.action;
import com.opensymphony.xwork2.ActionSupport;
public class RegistrationAction extends ActionSupport {
return username;
this.username = username;
return password;
this.password = password;
return email;
}
this.email = email;
@Override
return SUCCESS;
1. Create struts.xml:
Program
<struts>
<result name="success">/success.jsp</result>
<result name="input">/registration.jsp</result>
</action>
</package>
</struts>
Program
<html>
<head>
<title>Registration Successful</title>
</head>
<body>
<h2>Registration Successful!</h2>
</body>
</html>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>registration.jsp</welcome-file>
</welcome-file-list>
</web-app>
1. Create a Server:
In the Servers view in Eclipse, right-click and select New > Server.
result