I have been working on struts for a long time.
I am simulating programmatic validations and conversion errors in an application using Struts 2.
In my application I have a model class called Product which is as shown below:
public class Product {
private String productId;
private String productName;
private int price;
public Product() {}
public Product(String productId, String productName, int price) {
this.productId = productId;
this.productName = productName;
this.price = price;
}
public String getProductId() {
return productId;
}
public void setProductId(String productId) {
System.out.println("Product.setProductId() : '"+productId+"'");
this.productId = productId;
System.out.println("This.pid : "+this.productId);
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
System.out.println("Product.setProductName() : '"+productName+"'");
this.productName = productName;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
System.out.println("Product.setPrice() : '"+price+"'");
this.price = price;
}
}
I have jsp called ProductForm.jsp where I ask user to enter product info like below:
<%#taglib uri="/struts-tags" prefix="s" %>
<html>
<head>
<title>Add Product Form</title>
<style type="text/css">#import url(css/main.css);</style>
</head>
<body>
<div id="global">
<h3>Add a product</h3>
<s:form method="post" action="Product_Save.action">
<s:textfield label="Id" key="productId"/>
<s:textfield label="Name" key="productName"/>
<s:textfield label="Price" key="price"/>
<s:submit value="Add Product"/>
</s:form>
<s:debug/>
</div>
</body>
</html>
If user clicks on Add Productbutton by giving correct info data will be saved to database according to normal flow which is configured in struts.xml which is as below:
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="product_module" extends="struts-default">
<action name="Product_Input">
<result>/jsp/ProductForm.jsp</result>
</action>
<action name="Product_Save" class="com.way2learnonline.ui.ProductAction">
<result name="success">/jsp/ProductDetails.jsp</result>
<result name="input">/jsp/ProductForm.jsp</result>
<param name="test">MyTest</param>
</action>
</package>
</struts>
My Action class is ProductAction which is as shown below:
public class ProductAction extends ActionSupport implements ModelDriven<Product>{
private static final long serialVersionUID = 1L;
private Product product;
private String test;
public ProductAction() {}
public String execute(){
DatabaseManager databaseManager=new DatabaseManager();
databaseManager.write(product);
return Action.SUCCESS;
}
#Override
public void validate() {
System.out.println("p : "+product.getProductId());
if(product.getProductId().trim().equals("")){
addFieldError("productId", "Product Id should be present");
}
if(product.getPrice()<=0){
addFieldError("price", getText("price.negative"));
}
}
#Override
public Product getModel() {
product=new Product();
return product;
}
public void setTest(String test) {
this.test = test;
}
public String getTest() {
return test;
}
}
If we give invalid data like price less than or equal to zero or productId is empty then validation will be triggered.
If we give alphabets in price field then conversion error will be triggered.
But If I give alphabets in price field then my product object all variables are becoming nulls while it goes to validate() method, which is resulting null pointer exception in validate() method when I try to access productId from product object of ProductAction class.
Here why is my product object variables of ProductAction class are becoming null if I give alphabets in price field in ProductForm.jsp.
Put the model initialization in the declaration, not in the getter:
private Product product = new Product();
#Override
public Product getModel() {
return product;
}
Related
I'm working an a project where I need the Array of Objects values from One Action Class to another.
The flow goes something like this:
Try1.java --> first.jsp --> Try2.java
I'm not able to get the Array of Objects values in Try2.java.
It's always null.
User.java
package com.sham;
public class User {
private int id;
private String name;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Try1.java
package com.sham;
import java.util.ArrayList;
import com.opensymphony.xwork2.ActionSupport;
public class Try1 extends ActionSupport{
ArrayList<User> list=new ArrayList<User>();
public ArrayList<User> getList() {
return list;
}
public void setList(ArrayList<User> list) {
this.list = list;
}
public String execute(){
User user1=new User();
user1.setId(123);
user1.setName("John");
list.add(user1);
User user2=new User();
user2.setId(345);
user2.setName("Jen");
list.add(user2);
System.out.println("List " + list);
return "success";
}
}
struts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="default" extends="struts-default">
<action name="click" class="com.sham.Try1" >
<result name="success">first.jsp</result>
</action>
<action name="next" class="com.sham.Try2" >
<result name="success">second.jsp</result>
</action>
</package>
</struts>
first.jsp
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%# taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<s:form action="next">
Hello
<s:submit value="submit"/>
</s:form>
</body>
</html>
Try2.java
package com.sham;
import java.util.ArrayList;
import com.opensymphony.xwork2.ActionSupport;
public class Try2 extends ActionSupport {
ArrayList<User> list;
public ArrayList<User> getList() {
return list;
}
public void setList(ArrayList<User> list) {
this.list = list;
}
public String execute(){
System.out.println("List from Action class 2 " + getList());
return "success";
}
}
On clicking the submit button in first.jsp, the control goes to the Try2.java action class.
In Try2.java, I get null in getList().
I mean to say that, generally having getters and setters would work to get the values from one Action Class to another using hidden properties. But, in case of Array of Objects, it does not work the same, and the values are null.
In this case I want to get the Array of Object values for user 1 and user 2 in Try2.java.
I want to know how to get the same Array of Objects in the Try2.java from Try1.java action class.
This question already has answers here:
How to map an entity field whose name is a reserved word in JPA
(8 answers)
Closed 4 years ago.
I'm making simple Spring MVC library app, using Freemarker, MySQL and Hibernate,
i created form for adding new book to the library, it's code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Create new user</title>
</head>
<body>
<form name="booker" action="/newBook" method="post" >
<p>Name</p>
<input title="Name" type="text" name="name">
<p>Desc</p>
<input title="Email" type="text" name="desc">
<p>Author</p>
<input title="Age" type="text" name="aut">
<p>Year</p>
<input title="Age" type="text" name="year">
<input type="submit" value="OK">
</form>
</body>
</html>
Also i have Controller, BookDAO, BookService and Book entity
Controller:
#Controller
#RequestMapping("/")
public class BookController {
#Autowired
private BookService service;
#GetMapping("/books")
public String viewAll(Model model){
model.addAttribute("books",service.findAll());
return "books";
}
#GetMapping("/addBook")
public String addBook(){
return "createBook";
}
#PostMapping("/newBook")
public String newBooks(#ModelAttribute("booker") Book book){
service.add(book);
return "redirect:/books";
}
}
Entity:
#Table(name = "booker")
#Entity
public class Book {
private int id;
#Id
#GeneratedValue(strategy= GenerationType.AUTO)
#Column(name = "idbooker")
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
private String name;
private String desc;
private String aut;
private int year;
#Column(name = "name")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
#Column(name="desc")
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
#Column(name = "aut")
public String getAut() {
return aut;
}
public void setAut(String author) {
this.aut = author;
}
#Column(name = "year")
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
}
When i try to post new book, i get this exception, database columns' names are same can somebody tell how to fix it, ty.
Could be you have some issue with desc (reserved word) try using backtics
#Column(name="`desc`")
I am trying to show table value to JSP page but it not showing. I am trying it for one week.
product.java
This is model class of product
package com.practice.models;
public class Product {
private int id;
private String name;
private int qty;
private double price;
public Product(){}
public Product(int proId,String productName,int proQty,double proPrice){
this.id = proId;
this.name = productName;
this.qty = proQty;
this.price = proPrice;
}
public String getProductname() {
return name;
}
public void setProductname(String productname) {
this.name = productname;
}
public int getQty() {
return qty;
}
public void setQty(int qty) {
this.qty = qty;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
Struts.xml
<struts>
<package name="default" extends="struts-default">
<action name="checkonce" class="com.practice.controllers.GetProductList">
<result name="success">products.jsp</result>
<result name="error">error.jsp</result>
</action>
</package>
</struts>
GetProductList.java
I am Getting value from Database from DBtool class and I am getting all value successfully but values are not showing in the JSP file
public class GetProductList extends ActionSupport {
private static final long serialVersionUID = 1L;
private List<Product> productlist;
public List<Product> getproductlist(){
return productlist;
}
public void setproductlist(List<Product> productlist) {
this.productlist = productlist;
}
public String execute() throws IOException{
List<Product> productlist = new ArrayList<Product>();
try{
DBtool db = new DBtool();
System.out.println(1);
java.sql.ResultSet rs = db.getlist();
while(rs.next()){
int id = rs.getInt("id");
String proname = rs.getString("name");
int qty = rs.getInt("qty");
double price = rs.getDouble("price");
Product pro = new Product(id,proname,qty,price);
productlist.add(pro);
System.out.println(rs.getString("name"));
}
return SUCCESS;
}
catch(Exception ex){
System.out.println("Error : "+ex.getMessage());
return ERROR;
}
}
}
And This is products.jsp
<%# taglib uri="/struts-tags" prefix="s" %>
<table>
<thead>
<tr>
<th>Product ID</th>
<th>Product Name</th>
<th>Product Quantity</th>
<th>Product Price</th>
</tr>
</thead>
<tbody>
<s:iterator value="productlist" status="productlistStatus">
<tr>
<td><s:property value="id"/></td>
<td><s:property value="name"/></td>
<td><s:property value="qty"/></td>
<td><s:property value="price"/></td>
</tr>
</s:iterator>
</tbody>
</table>
productlist has the wrong scope in execute(). You declare it there again, so the scope of the variable is that method. You're not using the field. To solve it, remove the declaration in the execute() method, so it just says:
productlist = new ArrayList<>();
Also, Struts will be looking for a method getProductlist(). You should adapt the Java Bean naming convention.
I want to display an instance of the company pojo from the database. All I am able to display is the CompanyId the rest of the details are not getting displayed.
viewCompany.jsp
`<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%# taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<s:form action="ViewCompany">
<s:textfield name="companyId" label="Enter Company ID">
<s:param name="companyId" value="company.companyId"></s:param>
</s:textfield>
<s:submit/>
</s:form>
</body>
</html>
`
I am trying to enter the companyId and the values corresponding to the id should be displayed to the display page.
CompanyBean:
`package com.buhin.POJO;
public class Company {
private int companyId;
public String companyName;
public String contactPerson;
public String mobileNumber;
public String officeNumber;
public String mail;
public String addressLine1;
public String addressLine2;
public String cityName;
public String stateName;
public String zipcode;
//public Address address;
public Company(){}
public Company(int companyId){
this.companyId = companyId;
}
public int getCompanyId() {
return companyId;
}
public void setCompanyId(int companyId) {
this.companyId = companyId;
}
public String getCompanyName() {
return companyName;
}
public String getContactPerson() {
return contactPerson;
}
public String getMobileNumber() {
return mobileNumber;
}
public String getOfficeNumber() {
return officeNumber;
}
public String getMail() {
return mail;
}
public String getAddressLine1() {
return addressLine1;
}
public String getAddressLine2() {
return addressLine2;
}
public String getCityName() {
return cityName;
}
public String getStateName() {
return stateName;
}
public String getZipcode() {
return zipcode;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public void setContactPerson(String contactPerson) {
this.contactPerson = contactPerson;
}
public void setMobileNumber(String mobileNumber) {
this.mobileNumber = mobileNumber;
}
public void setOfficeNumber(String officeNumber) {
this.officeNumber = officeNumber;
}
public void setMail(String mail) {
this.mail = mail;
}
public void setAddressLine1(String addressLine1) {
this.addressLine1 = addressLine1;
}
public void setAddressLine2(String addressLine2) {
this.addressLine2 = addressLine2;
}
public void setCityName(String cityName) {
this.cityName = cityName;
}
public void setStateName(String stateName) {
this.stateName = stateName;
}
public void setZipcode(String zipcode) {
this.zipcode = zipcode;
}
#Override
public String toString() {
return "Company [CompanyName=" + getCompanyName()
+ ", ContactPerson=" + getContactPerson()
+ ", MobileNumber=" + getMobileNumber()
+ ", OfficeNumber=" + getOfficeNumber() + ", Mail="
+ getMail() + ", AddressLine1=" + getAddressLine1()
+ ", AddressLine2()=" + getAddressLine2()
+ ", CityName()=" + getCityName() + ", StateName="
+ getStateName() + ", Zipcode=" + getZipcode()
+ "]";
}
}
ViewCompany.java(ActionClass)
`
package com.buhin.Action;
import com.buhin.POJO.*;
import com.buhin.DAO.*;
import com.opensymphony.xwork2.ActionSupport;
public class ViewCompany extends ActionSupport {
/**
*
*/
private static final long serialVersionUID = 1L;
private int companyId;
Company company;
public Company getCompany(){
return company;
}
public void setCompany(Company company){
this.company = company;
}
public int getCompanyId(){
return companyId;
}
public void setCompanyId(int companyId){
this.companyId = companyId;
}
public String execute(){
CompanyDAO cdao = new CompanyDAO();
company = cdao.viewCompany(companyId);
//System.out.println(company.toString());
return "success";
}
}
CompanyDAO:
`package com.buhin.DAO;
import com.buhin.POJO.*;
import com.buhin.hibernate.*;
import com.opensymphony.xwork2.ActionSupport;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.SessionFactory;
public class CompanyDAO extends ActionSupport{
public CompanyDAO(){
}
/**
*
*/
private static final long serialVersionUID = 1L;
Company vCompany;
public String addCompany(Company company){
SessionFactory sessionfactory = HibernateUtil.getSessionFactory();
Session session = sessionfactory.openSession();
Transaction transaction = session.beginTransaction();
session.save(company);
transaction.commit();
session.close();
return "success";
}
public Company viewCompany(int companyId){
SessionFactory sessionfactory = HibernateUtil.getSessionFactory();
Session session = sessionfactory.openSession();
vCompany = (Company) session.get(com.buhin.POJO.Company.class, companyId);
return vCompany;
}
}
`
companydetails.jsp:
`<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%# taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<s:property value="company.companyId"/>
<s:property value="company.companyName"/>
<s:property value="company.contactPerson"/>
<s:property value="company.mobileNumber"/>
<s:property value="company.officeNumber"/>
<s:property value="company.mail"/>
<s:property value="company.addressLine1"/>
<s:property value="company.addressLine2"/>
<s:property value="company.cityName"/>
<s:property value="company.stateName"/>
<s:property value="company.zipcode"/>
</body>
</html>`
`
Struts.xml:
`<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="true"></constant>
<package name="com.buhin.POJO" extends="struts-default">
<!-- <action name="AddCompany" class="com.buhin.Action.AddCompany" method="execute">
<result name="success">/success.jsp</result>
</action>
--> <action name="ViewCompany" class="com.buhin.Action.ViewCompany" method="execute">
<result name="success">/companydetails.jsp</result>
</action>
</package>
</struts>
`
First of all I agree with #Aleksandr M, this is a very bizarre structure. But nevertheless, there are a few things wrong with this code.
1) You are returning 'success' result from action methods, so your result should be <result name="success">/companydetails.jsp</result>
2) You are storing Company object in local variable(Company viewCompany). This will not be available in your JSP.
What you should do is make a object variable. Add setter-getters for that variable and use it in your JSP as follows.
<s:property value="viewCompany.zipcode"/>
Hope this helps.
In my application I am trying to register a user by adding his details to the database and after success fully insert these values. I need to display form input page but on result page I am not getting any output.
My ACTION CLASS IS
package action;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import dao.Empdao;
import model.Empmodel;
public class Empaction extends ActionSupport implements ModelDriven<Object>{
private static final long serialVersionUID = 1L;
Empmodel modelobj;
public Empmodel getModelobj() {
return modelobj;
}
public void setModelobj(Empmodel modelobj) {
this.modelobj = modelobj;
}
public String execute() throws Exception{
Empdao empdao = new Empdao();
int queryResult = empdao.registration(modelobj);
if (queryResult==0)
{
addActionError("it is a dublicate entry please enter anothe id");
return ERROR;
}
else{
return SUCCESS;
}
}
#Override
public Object getModel() {
modelobj = new Empmodel();
return null;
}
}
Success.jsp is
<body>
first name : <s:property value="modelobj.firstname"/> <br>
last name :<s:property value="modelobj.lastname" />
<s:property value="modelobj.id" />
<s:property value="modelobj.gender" />
<s:property value="modelobj.dob" />
<s:property value="modelobj.maritalstatus" />
<s:property value="modelobj.email" />
<s:property value="modelobj.joiningdate" />
<s:property value="modelobj.designation" />
<s:property value="modelobj.country" />
<s:property value="modelobj.state" />
<s:property value="modelobj.city" />
<s:property value="modelobj.pincode" />
<s:property value="modelobj.mobileno" />
<s:property value="modelobj.groups" />
</body>
</html>
Empmodel CLASS IS
package model;
public class Empmodel {
private String firstname;
private String lastname;
private String id;
private String gender;
private String dob;
private String maritalstatus;
private String email;
private String joiningdate;
private String designation;
private String address;
private String country;
private String state;
private String city;
private int pincode;
private long mobileno;
private String groups;
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 getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getDob() {
return dob;
}
public void setDob(String dob) {
this.dob = dob;
}
public String getMaritalstatus() {
return maritalstatus;
}
public void setMaritalstatus(String maritalstatus) {
this.maritalstatus = maritalstatus;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getJoiningdate() {
return joiningdate;
}
public void setJoiningdate(String joiningdate) {
this.joiningdate = joiningdate;
}
public String getDesignation() {
return designation;
}
public void setDesignation(String designation) {
this.designation = designation;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public long getMobileno() {
return mobileno;
}
public void setMobileno(long mobileno) {
this.mobileno = mobileno;
}
public String getGroups() {
return groups;
}
public void setGroups(String groups) {
this.groups = groups;
}
public int getPincode() {
return pincode;
}
public void setPincode(int pincode) {
this.pincode = pincode;
}
}
struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="true"/>
<constant name="struts.devmode" value="true"/>
<package name="loginmodel" extends ="struts-default">
<action name ="emplogin" class ="action.Empaction">
<result name= "wait">/Registration/wait.jsp</result>
<result name = "input">/Registration/empregistration.jsp</result>
<result name ="success" type="redirect" >/Registration/success.jsp</result>
<result name="error">/Registration/empregistration.jsp</result>
</action>
</package>
empregistration.jsp
<%# page language ="java" contentType ="text/html; charset=ISO-8859-1" pageEncoding ="ISO-8859-1"%>
<%# taglib uri="/struts-tags" prefix="s"%>
<%# taglib uri="/struts-dojo-tags" prefix="sx" %>
<html>
<head>
<sx:head/>
<script type="text/javascript" src ="script.js"></script>
</head>
<body>
<div align="center"> <h1 style="color: red"> ENPLOYEE REGISTRATION FORM</h1>
<s:form action="emplogin" method="post">
<s:textfield name="modelobj.firstname" label="Employee Firstname"/>
<s:textfield name ="modelobj.lastname" label ="Last name"/>
<s:textfield name ="modelobj.id" label="Id"/>
<s:radio name ="modelobj.gender" list="{'male', 'female'}" label = "Gender"/>
<sx:datetimepicker name="dob" displayFormat="dd-MMM-yyyy" label="DOB"></sx:datetimepicker>
<s:radio name ="modelobj.maritalstatus" list="{'singale','married'}" label="Marital Status" />
<s:textfield name ="modelobj.email" label ="Email"/>
<sx:datetimepicker name ="modelobj.joiningdate" displayFormat="dd-MMM-yyyy" label="Joining Date"></sx:datetimepicker>
<s:textfield name= "modelobj.designation" label = "Designation"/>
<s:textarea name ="modelobj.address" label ="Address" />
<s:textfield name = "modelobj.country" label ="Country" />
<s:textfield name ="modelobj.state" label = "State" />
<s:textfield name ="modelobj.city" label ="City"/>
<s:textfield name ="modelobj.pincode" label ="Pincode"/>
<s:textfield name ="modelobj.mobileno" label="Mobile No"/>
<s:select name ="modelobj.groups" list="{'group 1', 'group 2', 'group 3'}" label ="Group" cssStyle="{width:184px"/>
<tr><td> </td></tr>
<tr>
<td> </td>
<s:submit align="center"></s:submit>
</s:form>
</div>
</body>
</html>
You are redirecting the page on success that is wrong because you loose values needed to display results. Use
<result name ="success">/Registration/success.jsp</result>
or simply
<result>/Registration/success.jsp</result>
BTW, you only have getters & setters for firstname and lastname, so the only these properties will display. If you want to display other properties then you should add correcponding methods to fields.
You may read the servlet API javadoc to make clue what may cause result type="redirect".
For further compare the difference between forward and redirect results consider this thread.
If type=redirectAction then you have to mention the Action name without any extensions
if its only redirect then you have to mention including the action name and extension, For your Question it was because of redirect the problem happened.
Even after redirecting to some page and when you come back to the result page , and if you want to retain data then its better you better put in session .
Do not redirect you page remove it and use
<result name ="success">/Registration/success.jsp</result> in you struts.xml file