Write A Login Forward

Write A Login Forward

Previous Home Next

 

Here in this section we are going to create a JSP View where Action Servlet forward the request coming from Action class .This request is forwarded to client as a response. The Action Servelet decides JSP View on the behalf of key returned by Action class.

 For this create a JSP page (e.g. success.jsp ). Configure this JSP page in struts-config.xml in tag .e.g Here success (name=”success”) is key returned by subclass of appropriate Action class. The action class ma return any key. As par as key we can configure JSP.

struts-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC 
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" 
"http://struts.apache.org/dtds/struts-config_1_3.dtd">
<struts-config>
<form-beans>
<form-bean name="loginForm" type="com.r4r.struts.LoginForm"/>
</form-beans>
<global-exceptions />
<global-forwards>
<forward name="login" path="/login.do"/>
</global-forwards>
<action-mappings>
<action path="/login" type="com.r4r.struts.LoginAction" name="loginForm">
<forward name="success" path="/success.jsp"/>
<forward name="error" path="/error.jsp"/>
</action>
</action-mappings>
<message-resources parameter="com.r4r.struts.ApplicationResources"/>
</struts-config>

Previous Home Next