|
Struts Dispatch Action Tutorial with example
|
|
12-12-2011, 08:56 PM
(This post was last modified: 12-18-2011 09:43 PM by rajasri.)
Post: #1
|
|||
|
|||
|
Struts Dispatch Action Tutorial with example The two package which needed to be imported are as follows import org.apache.struts.action.DispatchAction; import org.apache.struts.action.ActionForm; The Main features of Dispatch Action are *One of the Built in Functions in Struts Framework *The class doesnot provide implement action for the execute() method,Because dispatch action class iteself implements the method. *It eliminates the need of creating multiple independent actions Lets create a jsp page which calls the dispatch action classes in struts-config.xml <%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %> Quote:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> In dispatch action.java file we can redirect the form using different functions, so we don't need to use default execute() method [java lines="50"] package com.s2sgateway.action; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.actions.DispatchAction; import com.s2sgateway.form.DispatchForm; public class DispatchAction1 extends DispatchAction { public ActionForward tutorial(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { return mapping.findForward("tutorial"); } public ActionForward downloads(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { return mapping.findForward("downloads"); } } In struts-config.xml we can define the forward name and path to be redirected Quote:<?xml version="1.0" encoding="UTF-8"?> The other file named dispatch.java is doing a same function as index.jsp but it gets the parameter value in textbox rather than link dispatchs2sgateway. Happy coding
|
|||
Advertise here or at any positions around our site send a mail to info@walkinsforum.com
|
« Next Oldest | Next Newest »
|
![]() |
|||||||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|
| Possibly Related Threads... | |||||
| Thread: | Author | Replies | Views: | Last Post | |
| Struts hiberanate integration tutorial part2 | rajasri | 9 | 1,438 |
05-02-2012 04:29 PM Last Post: admin |
|
| Struts hiberanate integration tutorial part2 | admin | 1 | 318 |
05-02-2012 02:36 PM Last Post: lalithakotha |
|
| Login form authentication using Struts with database | mjm | 1 | 1,973 |
04-27-2012 03:57 PM Last Post: alexrabe |
|
| Simple Struts-Hibernate Integration tutorial to insert values | rajasri | 2 | 3,539 |
01-15-2012 01:40 PM Last Post: mukesh1234 |
|
| Simple Struts Example | rajasri | 0 | 397 |
12-14-2011 11:17 AM Last Post: rajasri |
|
| How to export data as pdf in struts using displaytags | rajasri | 0 | 1,018 |
12-12-2011 06:38 PM Last Post: rajasri |
|
User(s) browsing this thread: 1 Guest(s)






![[-]](images/royal_red/collapse.gif)






