Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing parameters from Action to next jsp

Status
Not open for further replies.

Kafenated

Programmer
May 8, 2003
11
0
0
IN
I have a login page after validating the user and password I would like to pass the user to a welcome page to display
WELCOME +user
Here is my Struts-Config.xml
<?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot; ?>

<!DOCTYPE struts-config PUBLIC
&quot;-//Apache Software Foundation//DTD Struts Configuration 1.1//EN&quot;
&quot;


<struts-config>

<!-- ======== Form Bean Definitions =================================== -->
<form-beans>
<form-bean name=&quot;LoginForm&quot; type=&quot;database.LoginForm&quot;/>
</form-beans>

<!-- ========== Action Mapping Definitions ============================== -->
<action-mappings>
<!-- Say Hello! -->
<action path = &quot;/Login&quot;
type = &quot;database.LoginAction&quot;
name = &quot;LoginForm&quot;
scope = &quot;request&quot;
validate = &quot;true&quot;
input = &quot;/jsp/Login.jsp&quot; >

<forward name=&quot;LoggedIn&quot; path=&quot;/jsp/Logged.jsp&quot; />
</action>
</action-mappings>

<!-- ========== Message Resources Definitions =========================== -->

<message-resources parameter=&quot;database.ApplicationResources&quot;/>

</struts-config>

Here is the action
with the Find Forward

(mapping.findForward(&quot;LoggedIn&quot;));
 
/*in the action subclass corresponding to LogIn.jsp */
request.setAttribute(&quot;user&quot;, userFromLogInJsp );

// Forward control to the specified success target
return (mapping.findForward(&quot;LoggedIn&quot;));


/*In the actionForm corresponding to Logged.jsp ,say LoggedForm there would be set/get method for property &quot;user&quot; as
*/
private String user = null;

public String getUser() {
return (this.user);
}
public void setUser(String user) {
this.user = user;
}

/*in Logged.jsp*/

<logic:present name=&quot;user&quot; scope=&quot;request&quot;>
Welcome <bean:write name=&quot;user&quot; scope=&quot;request&quot;/>
</logic:present>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top