JSP Tutorials

JSP Action
Previous Home Next
adplus-dvertising

Jsp Action

In JSP is actions used a constructs in XML syntax to control and behaviour of the servlet engine. We can dynamically insert a file, reuse JavaBeans components, forward the user to another page, or generate HTML for the Java plugin.

There is only one syntax for the Action element, as it conforms to the XML standard:

Syntax used

<jsp:action_name attribute="value"/>

Some important Action tags

SyntaxPurpose
jsp:includeIncludes a file at the time the page is requested
jsp:useBeanfind javaBean
jsp:setPropertySets JavaBean property
jsp:getPropertyinserts the property of a JavaBean into the output
jsp:forwardForwards the requester to a new page
jsp:pluginA specific code which makes an OBJECT or EMBED tag of Javaplugin
jsp:elementDefines XML element

jsp:forward action tag

It can be used to forward the request to another resource it may be jsp.

Syntax used without parameter

    <jsp:forward page="relativeURL | <%= expression %>">  
    <jsp:param name="parametername" value="parametervalue | <%=expression%>" />  
    </jsp:forward>  

    <jsp:forward page="relativeURL | <%= expression %>">  
    <jsp:param name="parametername" value="parametervalue | <%=expression%>" />  
    </jsp:forward> 

Example

index.jsp
    <html>  
    <body>  
    <h2>this is index page</h2>  
    <jsp:forward page="printdate.jsp" />  
    </body>  
    </html>  

    <html>  
    <body>  
    <h2>this is index page</h2>  
    <jsp:forward page="printdate.jsp" />  
    </body>  
    </html>  
printdate.jsp
    <html>  
    <body>  
    <% out.print("Today is:"+java.util.Calendar.getInstance().getTime()); %>  
    </body>  
    </html>  

    <html>  
    <body>  
    <% out.print("Today is:"+java.util.Calendar.getInstance().getTime()); %>  
    </body>  
    </html>  
Previous Home Next