Tell a friend
Link to us
Bookmark Us
Total Members
      Members: 87089
Sitemap Forum Chat
 
JSP Home
JSP Members (19556)
JSP Member Articles ( 11 )
JSP Discussion (77)
JSP Q & A ( 97 )
- JSP Ask Question
- JSP Questions
- JSP Unanswered Questions
JSP Resources
JSP Source Code (172)
JSP Articles (34)
JSP Blogs (338)
JSP Jobs (40)
JSP Components (10)
JSP Books (10)
JSP Websites (13)
JSP News (12)

 
Resource Directory
Beans (0)
Books & Media (0)
Community (0)
Graphics & Charts (1)
JSP Videos (0)
JSP Web Hosting (0)
Other JSP Sites (0)
References (0)
Software & Server (0)
Tag Libraries (0)
Tutorials & Code Snips (0)
Web Applications (1)

 
GROUP INFO
Members: 19556
Access Type: Anyone can join

 
GROUPS
.NET
ASP.NET
.NET
C#
ASP
Visual Basic
Java
Java
JSP
EJB
Other
Delphi
C++
Ajax
UML
JavaScript
PHP
Web Design
Web Hosting
SQL Server
Oracle
Project Management
More Groups

 
LEARNING CENTER
TUTORIALS
.NET
.NET Tutorial
ASP Tutorial
ASP.NET Database Tutorial
ASP.NET Development Tips
ASP.Net Security,Internationalisation And Deployment
ASP.NET Server Controls Tips
ASP.NET Tutorial
C Sharp Tutorial
LINQ Tutorial
Web Development
Flex Tutorial
HTML Tutorial
Javascript Tutorial
Learn AJAX Tutorial
PHP Tutorial
Software Development
Database Tutorial
SQL Tutorial
UML Tutorial
Java
Ant Tutorial
EJB 3 Tutorial
Grails Tutorial
Hibernate Tutorial
Java 1.6 Tutorial
Java Tutorial
Java Web Component Tutorial
Java XML Tutorial
JDBC Tutorial
JDK1.5 Tutorial
JSF Tutorial
JSP And J2EE Design Tutorial
JSP Tutorial
Service-Oriented Architecture (SOA) Tutorial For Managers
Spring Tutorial
Struts Tutorial
Tomcat Tutorial

RESOURCES
Q & A (531 )
Source Code (3276 )
Articles (365 )
Books (373 )
Components (1647 )
News (898 )
Websites (1208 )

SUBMISSIONS
Submit Article
Submit Website
Submit News
Submit Source Code
Submit Component

COMMUNITY
Authors
Members Directory
Discussion Forum
Chat

SITE
About Us
Sitemap
Search
Contact Us
Feedback
Tell a Friend
Advertise

 

Home > JSP > Member Articles > Fundamentals >
 

Struts Tutorial


  Author : VisualBuilder.com
  Date Published : 03/24/2007
  Accessed : 37006
   visualbuilder
<< Back  Next >> 


Adding a form bean is a two step process. First of all we need to declare the form bean in the <form-beans> tag. Then we can associate this form bean to as many actions as we want. To declare the form bean,add the following line in the <form-beans> tag.


<form-bean name="loginForm" type="com.visualbuilder.struts.beans.User" />


Now we will associate this form bean with the LoginAction. Update the action tag in action-mappings so that it becomes like this.


 <action     


      name="loginForm"


      path="/login"


      scope="request"


      type="com.visualbuilder.struts.action.LoginAction"


      validate="false">


      <forward name="failure" path="/index.jsp" />


      <forward name="success" path="/manageusers.jsp" />


 </action>


Now update the LoginAction to retrieve form values from form bean instead of request object though they are still available in the request object s well. Execute method should look like this now.


public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)
{
            User userForm = (User)form;
            String user = userForm.getUserId();
            String password = userForm.getPassword();
            if(user!=null && password!=null && user.equals("admin") && password.equals("admin"))
                return mapping.findForward("success");
            return mapping.findForward("failure");
}


Again deploy and run the project. You should get the same behavior as you got earlier.


Pages   << Back  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60  Next >>  Next: Part 18: Using Struts Tag Libraries >>

 
   Printer Friendly
   Email to a friend
   Add to my Favourites  Report Bad Submissions  Submit Feedback
  Download PDF version
 
                 Click each image to add
this page to each site.
 
Related Articles of JSP
Previous Article    -     Random Articles    -     Next Article
 
 
 
 
 
 
 
 
Welcome Guest Signup
Member's Panel
EMAIL
PASSWORD
Forgot your password?
New User? Click Here!
 
Resend Activation Email!

SEARCH
 



 
 
 
 
 


Home | Login | About Us | Contact Us | Privacy Policy | Advertising | Feedback Please