I am doing registration using Struts and Hibernate here and I am facing a problem like when I run my project I get
localhost/ProjectName/registration.jsp
when I submit the data, data successfully saved in database, after saving data in database I am looking for registration.jsp
as response page but that time URL will be
localhost/ProjectName/actionName.action
this would create a problem like if I refresh page the last added record will be added again
JSP Form:
<s:form action="register">
</s:form>
struts.xml
:
<action name="register" class="-----------">
<result name="success">registration.jsp</result>
</action>
You should follow PRG pattern mentioned in this answer.
Create a new action
registrationSuccess
that will return your JSP page after redirect action result.You can use
store
Interceptor to store action messages/errors in HTTP session. The action class should implementValidationAware
.The
store
interceptor works between two actions, one of them store the messages, another retrieve them.