Previous | Home | Next |
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
Syntax | Purpose |
jsp:include | Includes a file at the time the page is requested |
jsp:useBean | find javaBean |
jsp:setProperty | Sets JavaBean property |
jsp:getProperty | inserts the property of a JavaBean into the output |
jsp:forward | Forwards the requester to a new page |
jsp:plugin | A specific code which makes an OBJECT or EMBED tag of Javaplugin |
jsp:element | Defines 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>
<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 |