Tell a friend
Link to us
Bookmark Us
Total Members
      Members: 87081
Sitemap Forum Chat
 
JSP Home
JSP Members (19554)
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: 19554
Access Type: Anyone can join

 

 
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 : 36732
   visualbuilder
<< Back  Next >> 

(2) ActionForm Class


 


package com.visualbuilder;


 


import org.apache.struts.action.ActionForm;


 


public class InputForm extends ActionForm{


}


(3) ActionClass


Note:- Now all the action classes must imherit the org.apache.struts.action.DispatchAction Class and not the org.apache.struts.action.Action Class.


 


package com.visualbuilder;


import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;


import org.apache.struts.action.ActionMessages;

import org.apache.struts.action.ActionForm;

import org.apache.struts.action.ActionForward;

import org.apache.struts.action.ActionMapping;

import org.apache.struts.action.ActionMessage;

import org.apache.struts.action.ActionMessages;

import org.apache.struts.actions.DispatchAction;


public class DispatchActionExample extends DispatchAction{


protected ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)

throws Exception {

                ActionMessages message = new ActionMessages();

                message.add("unspecified",new ActionMessage("error.unspecified"));

                saveMessages(request, message);

        return mapping.getInputForward();

}


public ActionForward view(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception{

                ActionMessages message = new ActionMessages();

                message.add("unspecified",new ActionMessage("error.view"));

                saveMessages(request, message);

        return mapping.getInputForward();

}

public ActionForward add(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception{

                ActionMessages message = new ActionMessages();

                message.add("unspecified",new ActionMessage("error.add"));

                saveMessages(request, message);

        return mapping.getInputForward();

}

public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {

                ActionMessages message = new ActionMessages();

                message.add("unspecified",new ActionMessage("error.delete"));

                saveMessages(request, message);

        return mapping.getInputForward();

}


}


(4) JSP Page


<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>

<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>

<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html:html>

<logic:messagesPresent>


<html:messages id="msg">

        <p><strong><font color="red"><bean:write name="msg" /></font></strong></p>

</html:messages>

</logic:messagesPresent>


<logic:messagesPresent message="true">

<html:messages message="true" id="msg">

        <p><strong><bean:write name="msg" /></strong></p>

</html:messages>

</logic:messagesPresent>


<html:form
action="/dispatchActionExample.do?method=add" method="post">

        <html:submit>Submit for add</html:submit>

</html:form>

<html:form
action="/dispatchActionExample.do?method=view" method="post">

        <html:submit>Submit for view
</html:submit>

</html:form>

<html:form
action="/dispatchActionExample.do?method=delete" method="post">

        <html:submit>Submit for delete
</html:submit>

</html:form>

<html:form
action="/dispatchActionExample.do" method="post">

        <html:submit>Submit for unspecified
</html:submit>

</html:form>


</html:html>


Output:-


The following buttons will be displayed and on clicking the buttons the text "delete called" changes



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 27: Introduction to DynaActionForm >>

 
   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

Warning: Unknown(): write failed: Disk quota exceeded (122) in Unknown on line 0

Warning: Unknown(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0