Class ActionForward in struts
Previous Home Next

An ActionForward represents a destination to which the controller, RequestProcessor, might be directed to perform a RequestDispatcher.forward or HttpServletResponse.sendRedirect to, as a result of processing activities of an Action class. ActionForward is class of org.apache.struts.action package and it has following minimal set of properties like:

  • name - The logical parameter which instance is mapping into ActionMapping in struts-config.xml.
  • path - The URI to which control should be forwarded/ redirected to a give destination.
  • contextRelative - Should the path value be interpreted as context-relative (instead of module-relative, if it starts with a '/' character)
  • redirect - Set true if the controller servlet should call HttpServletResponse.sendRedirect() on the associated path; otherwise false.

Three main subclass of ActionForward in org.apache.struts.action package-

  • ActionRedirect- Designed for redirecting all requests, with support adding parameters at runtime
  • RedirectingActionForward- Designed for redirecting the default attribute to false.
  • ForwardingActionForward- Designed for redirecting defaults attribute to true.

PlugIn Classes in struts

The PlugIn interface extends Action and so that applications can easily hook into the ActionServlet lifecycle. This interface defines two methods-

  • init() - method is called when application is startup.
  • destroy()- method is called when application is shutdown.

A common use of a Plugin Action is to configure or load application-specific data as the web application is starting up.At runtime, any resource setup by init would be accessed by Actions or business tier classes. The PlugIn interface allows you to setup resources, but does not provide any special way to access them. Most often, the resource would be stored in application context, under a known key, where other components can find it.

Previous Home Next