| Java Server Pages Overview |
| |
| JSP Tags |
| |
| As we saw earlier we can create and use our own custom tags inside a JSP page using the taglib directive. With that there are quite a few standard JSP tags which are part and parcel of the JSP specification and provide really useful functionality : |
| |
1. <jsp:include>
2. <jsp:forward>
3. <jsp:param>
4. <jsp:plugin> |
| |
| The <jsp:include> Tag |
| This jsp:include tag allows inclusion of the content of the given file within the JSP page at the request time. It is different from the include directive we studied above where the content of the file was included at translation time. |
| |
| It's syntax is as follows : |
| <jsp:include page="pathToFile" flush="true | false" /> |
| |
| The page attribute contains the path to the given file we want to include ( which can be a JSP page, Servlet or a simple HTML/text file ). In JSP compatible application servers (e.g, Tomcat 4.0) we can set the flush attribute to false. |
| |
| The <jsp:param> Tag |
| This tag is used inside the <jsp:include>, <jsp:forward> and <jsp:plugin> tags. |
| It defines and sets different parameters with their values .e.g, |
<jsp:include page="file.jsp" flush="true" %>
<jsp:param name="name" value="Aman Kumar" />
</jsp:include> |
| |
| In the code above a parameter with the name 'name' and a value of "Aman Kumar" has been provided to the included JSP page; file.jsp. The file.jsp page can access the value of this paramter by : |
<%
String name = request.getParamter("name");
%> |
| |
| The <jsp:forward> Tag |
| This tag allows us to forward the control to a given page. |
| |
| Its syntax is as follows: |
| <jsp:forward page="pathToFile" /> |
| |
| Where pathToFile is the path to the page we want control to be forwarded to. |
| Like <jsp:include> tag you can also use <jsp:param> to provide parameters to the forwarded page. |
| |
| The <jsp:plugin> Tag |
| This tag allows us to embed Java applets or beans in a web page. |
| |
| It's syntax is as follows : |
|
<jsp:plugin type="bean | applet" code="className"
codebase="path to root directory containing classes"
align="top | middle | bottom | left | right"
archives="jar files required for this app"
height="height in pixels" width="width in pixels"
hspace="horizontal space in pixels" vspace="vertical space"
jreversion="the JRE version required"
name="name of object"
nspluginurl="URL for Netscape plugin"
iepluginurl="URL For IE plugin">
|
<jsp:params>
<jsp:param name="name" value="value" />
</jsp:params> |
<jsp:fallback>
Sorry your browser doesn't support Java applets.
</jsp:fallback>
</jsp:plugin> |
| |
| Almost all the attributes for the <jsp:plugin> tag above are self explanatory. |
| |
| |
|
| |
| |