I am quite new to struts2. I have several Servlets in my web application and I wanted to change it so that I make use of the Struts2 framework. How do I go about doing this and keeping the same logic within the code? I am also using Hibernate and would also like to use Struts2 with Hibernate.

For instance, I have this servlet in my web application:

```
package com.webapp.servlets;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.hibernate.Session;

import com.webapp.entity.UserEntity;
import com.webapp.util.HibernateUtil;

/**
 * Servlet implementation class SignUpServlet
 */
@WebServlet("/SignUpServlet")
public class SignUpServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#HttpServlet()
     */
    public SignUpServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doProcess(request, response);
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doProcess(request, response);
    }

    protected void doProcess(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("in process");
        String userName = request.getParameter("userName");
        String password = request.getParameter("password");
        String email = request.getParameter("email");
        String firstName = request.getParameter("firstName");
        String lastName = request.getParameter("lastName");
        String contactNo = request.getParameter("contactNo");
        String address = request.getParameter("address");

        UserEntity userEntity = new UserEntity();

        userEntity.setUserName(userName);
        userEntity.setPassword(password);
        userEntity.setEmail(email);
        userEntity.setFirstName(firstName);
        userEntity.setLastName(lastName);
        userEntity.setAddress(address);
        userEntity.setContactNo(contactNo);

        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();

        session.save(userEntity);

        session.getTransaction().commit();

        response.sendRedirect("jsp/login.jsp");
    }
}

```

And the model

```
package com.webapp.entity;

import java.io.Serializable;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
@Entity
@Table(name = "Users")
public class UserEntity implements Serializable{

/**
 * 
 */
private static final long serialVersionUID = 1L;

@Id
@Basic(optional = false)
 @GeneratedValue(strategy= GenerationType.IDENTITY)
@Column(name = "userId")
private Long userId ;

@Column(name = "userName")
private String userName;

@Column(name = "password")
private String password;

@Column(name = "roleId")
private Long roleId;

@Column(name = "email")
private String email;

@Column(name = "firstName")
private String firstName;

@Column(name = "lastName")
private String lastName;

@Column(name = "address")
private String address;

@Column(name = "contactNo")
private String contactNo;

public String getFirstName() {
    return firstName;
}

public void setFirstName(String firstName) {
    this.firstName = firstName;
}

public String getLastName() {
    return lastName;
}

public void setLastName(String lastName) {
    this.lastName = lastName;
}

public String getAddress() {
    return address;
}

public void setAddress(String address) {
    this.address = address;
}

public String getContactNo() {
    return contactNo;
}

public void setContactNo(String contactNo) {
    this.contactNo = contactNo;
}

public Long getUserId() {
    return userId;
}

public void setUserId(Long userId) {
    this.userId = userId;
}

public String getUserName() {
    return userName;
}

public void setUserName(String userName) {
    this.userName = userName;
}

public String getPassword() {
    return password;
}

public void setPassword(String password) {
    this.password = password;
}

public Long getRoleId() {
    return roleId;
}

public void setRoleId(Long roleId) {
    this.roleId = roleId;
}

public String getEmail() {
    return email;
}

public void setEmail(String email) {
    this.email = email;
}

```

}

And the view which is SignUp.jsp

```
<head>
     </head>
        <body>

            <br></br>
            <br></br>
            <table width="" border="0" align="center" cellpadding="0"
                   cellspacing="0" class="maintable">
                <tr>
                    <td valign="top" align="center" class="middlesection">
                        <table width="96%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td>
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                        <tr>
                                            <td>
                                                <table width="100%" border="0" cellspacing="0"
                                                       cellpadding="0">
                                                    <tr>
                                                        <td align="left" valign="middle">
                                                            <h1>
                                                                Sign Up
                                                            </h1>
                                                        </td>
                                                        <td align="right" valign="bottom">
                                                            <table width="0%" border="0" cellspacing="0"
                                                                   cellpadding="0">
                                                                <tr>
                                                                    <td align="center" style="color: #00FF00">
                                                                        &nbsp;
                                                                    </td>
                                                                    <td>
                                                                        <a href="#" class="buttonash" onclick="resetForm();"><span>
                                                                                reset </span> </a>
                                                                    </td>
                                                                    <td width="5"></td>
                                                                    <td>
                                                                        <a href="#" class="buttonash" onclick="submit()"><span>
                                                                                SignUp </span> </a>
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="bottomboder">
                                                <img src="/WebApp/images/ashish.gif" height="1" />
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td></td>
                            </tr>
                            <tr>
                                <td>
                                    <div class="tab-content-out" style="clear: both">
                                        <div id="tabs" class="tabs">
                                            <div id="TabbedPanels1" class="TabbedPanels">

                                                <div
                                                    style="background: url(/WebApp/images/tabhdbg.gif) top repeat-x #ffffff; height: 70px;"
                                                    class="TabbedPanelsTabGroup">
                                                    <div style="width: 1px; float: left;">
                                                        <img src="/WebApp/images/tabhdline.gif" />
                                                    </div>
                                                    <div class="navi"
                                                         style="padding-left: 7px; padding-top: 9px;">
                                                        <div style="color: #4B5974; font-size: 24px;"
                                                             align="center">
                                                            <b>  SignUp Form</b>
                                                        </div>
                                                    </div>

                                                    <div style="width: 1px; float: right;">
                                                        <img src="images/tabhdline.gif" />
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="TabbedPanelsContentGroup">
                                                <div class="TabbedPanelsContent">
                                                    <div style="border: 0;" class="tab-content">
                                                        <div class="entry-edit">
                                                            <div class="tebelhd" align="left">
                                                                General Information
                                                            </div>
                                                            <div class="fieldset" id="_generalbase_fieldset">
                                                                <div class="hor-scroll" align="left">
                                                                    <table class="form-list" cellspacing="0" align="center">
                                                                        <tbody>
                                                                        <form method="get" id="addCustomer" name="addCustomer" action="/WebApp/SignUpServlet"  >
                                                                        <table>
                                                                            <tr>
                                                                                <td>
                                                                                    <label>First Name</label>
                                                                                </td>
                                                                                <td>
                                                                                    <input type="text"  name="firstName" required size="51" class="required-entry required-entry input-text"/>
                                                                                </td>
                                                                                </tr>
                                                                                <tr>
                                                                                <td>
                                                                                    <label>Last Name</label>
                                                                                </td>
                                                                                <td>
                                                                                    <input type="text"  name="lastName" size="51" class="required-entry required-entry input-text"/>
                                                                                </td>
                                                                                </tr>
                                                                                <tr>
                                                                                <td>
                                                                                    <label>Adddress</label>
                                                                                </td>
                                                                                <td>
                                                                                    <input type="text"  name="address" size="51" class="required-entry required-entry input-text"/>
                                                                                </td>
                                                                                </tr>
                                                                                <tr>
                                                                                    <td>
                                                                                        <label>Contact No.</label>
                                                                                    </td>
                                                                                    <td>
                                                                                        <input type="text"  name="contactNo" size="51" class="required-entry required-entry input-text"/>
                                                                                    </td>
                                                                                </tr>
                                                                                <tr>
                                                                                    <td>
                                                                                        <label>Email</label>
                                                                                    </td>
                                                                                    <td>
                                                                                        <input type="text"  name="email" size="51" class="required-entry required-entry input-text"/>
                                                                                    </td>
                                                                                </tr>
                                                                                <tr>
                                                                                    <td>
                                                                                        <label>UserName</label>
                                                                                    </td>
                                                                                    <td>
                                                                                        <input type="text"  name="userName" size="51" class="required-entry required-entry input-text"/>
                                                                                    </td>
                                                                                </tr>
                                                                                <tr>
                                                                                    <td>
                                                                                        <label>Password</label>
                                                                                    </td>
                                                                                    <td>
                                                                                        <input type="password"  name="password" size="51" class="required-entry required-entry input-text"/>
                                                                                    </td>
                                                                                </tr>
                                                                        </table>
                                                                             </form>

                                                                        </tbody>
                                                                    </table>

                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>

    </body>

</html>

```