Using Struts Scripting


Struts Scripting Overview

Struts Scripting essentially provides a wrapper around BSF for creating Struts Actions. Instead of writing standard actions in Java, you can write actions in any BSF-supported scripting language of your choice. The main benefit to writing actions in a scripting language (instead of using the traditional approach of coding them in Java) is that the development cycle can be sped up. Writing actions in Java requires action code to be edited and compiled and for the application to be reloaded in the servlet container the code is running on. Struts Scripting, however, significantly reduces development time by allowing the actions to be written in a scripting language that does not need to be recompiled and does not require the application to be reloaded in the servlet container.

To fully understand how Struts Scripting works, a brief architectural overview is in order. Struts Scripting provides a built-in Action subclass (org.apache.struts.scripting.ScriptAction) that is used to execute script-based actions. ScriptAction is configured in the Struts configuration file like any other action but with one additional parameter: the script to execute for the given action mapping. When executed, ScriptAction uses BSF to map the specified script's file extension to a particular language. Next, BSF uses the mapped language to execute the specified script. Each time the script is executed, it is re-read. That is the mechanism that allows actions to be modified without requiring the Web application to be reloaded in the servlet container it is running on.



Struts. The Complete Reference
Struts: The Complete Reference, 2nd Edition
ISBN: 0072263865
EAN: 2147483647
Year: 2004
Pages: 165
Authors: James Holmes

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net