An Action is a request time instruction given to the JSP engine. Actions are high-level JSP elements that create, modify, or use other objects. Actions are coded strictly according to the XML syntax. JSP specification defines two kinds of actions.
• Standard actions
• Custom actions
Standard Actions: – standard actions are those actions that are associated with standard tags, which are delivered with the JSP container. The container knows the meaning of these tags. Whenever standard action’s tag is encountered in a jsp, the container invokes built in functionality and the required action takes place. Every standard action is of the form <jsp:action attribute1 = "value" attribute2="value" />.
According to JSP specification the following are the important standard actions.
• plugin
• include
• forward
• param
• useBean
• setProperty
• getProperty
plugin standard action: – This standard action is used to insert an applet into the JSP page. This action is of the following form
<jsp:plugin type = "applet" code = "OurApplet.class" width = "200" height="200 />
include standard action: – The net effect of this standard action is equivalent to’ the RequestDispatcher’s include() method of the SERVLET API. include standard action is of the form <jsp:include page="resourcepathtoinclude" />. This standard action includes the output of the target jsp into the response of the main jsp at the time of main jsp is requested. This action works as follows.
When the client makes a request for the main jsp, the JSP container reads the entire page first. When it encounters the include standard action, it inserts a method call inline in the generated Servlet. That method call at runtime combines the response from the target jsp. The container generates servlets for both JSP files. param standard action: – In the include mechanism or forward mechanism; the included page(target jsp) uses the same request object as the originally requested page(main jsp). As a result, the included page normally sees the same request parameters as that of main jsp. If at all, we want to add or replace those parameters, we make use of param standard action. This action is of the following form.
<jsp:param name="paramname" value="paramvalue" />
Note:- include standard action is used in conjunction with include or forward standard action only.
forward standard action: – The net effect of this standard action is equivalent to the RequestDispatcher’s forward () method of the SERVLET API. forward standard action is of the form <jsp:forward page="resourcepathtoinclude" />. This standard action switches the control completely from the source jsp to the target jsp. And the target jsp is responsible to deliver the output to the client.
