The JSP Files (part 8): Tagged And Bagged - Applet Antics (Page 6 of 6 ) You've already seen how JSP "actions" work - in the last article, for example, we demonstrated the <jsp:useBean> and <jsp:setProperty> actions in conjunction with JavaBeans, while <jsp:include> was illustrated in the very first article in this series. However, we missed out on a couple of important ones - and so, we'd like to introduce you to <jsp:plugin>, used to incorporate Java applets into a Web page. The <jsp:plugin> directive takes care of generating all the HTML code necessary to embed and activate a Java applet. Consider the following example:
<html>
<head>
</head>
<body>
<jsp:plugin type="applet" code="NewsTicker.class" name="newsticker"
height="100" width="100">
<jsp:params>
<jsp:param name="x" value="10"/>
<jsp:param name="y" value="25"/>
<jsp:param name="cx" value="90"/>
<jsp:param name="cy" value="114"/>
<jsp:param name="bgcolor" value="102,102,153"/>
<jsp:param name="textcolor" value="0,0,0"/>
<jsp:param name="hilitecolor" value="255,0,0"/>
</jsp:params>
<jsp:fallback>Oops! Something bad happened and I can't display this
applet</jsp:fallback>
</jsp:plugin>
</body>
</html>
The code above sets up the applet contained in
"NewsTicker.class", and passes it a bunch of name-value pairs of parameters. The When JSP compiles and renders the page, the code above is automatically converted to its HTML equivalent.
<html>
<head>
</head>
<body>
<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" width="100"
height="100"
codebase="http://java.sun.com/products/plugin/1.2.2/jinstall-1_2_2-win.cab
#Version=1,2,2,0">
<PARAM name="java_code" value="NewsTicker.class">
<PARAM name="type" value="application/x-java-applet;">
<PARAM name="cy" value="114">
<PARAM name="cx" value="90">
<PARAM name="bgcolor" value="102,102,153">
<PARAM name="hilitecolor" value="255,0,0">
<PARAM name="y" value="25">
<PARAM name="x" value="10">
<PARAM name="textcolor" value="0,0,0">
<COMMENT>
<EMBED type="application/x-java-applet;" width="100" height="100"
pluginspage="http://java.sun.com/products/plugin/"
java_code="NewsTicker.class"
cy=114
cx=90
bgcolor=102,102,153
hilitecolor=255,0,0
y=25
x=10
textcolor=0,0,0
>
<NOEMBED>
</COMMENT>
Oops! Something bad happened and I can't display this applet
</NOEMBED></EMBED>
</OBJECT>
</body>
</html>
And finally, the
<jsp:forward page="endzone.jsp" />
Just as in the previous example, additional parameters can be
passed to the new script via <jsp:param>. For example,
<jsp:forward page="endzone.jsp">
<jsp:param name="user" value="joe" />
<jsp:param name="uid" value="653" />
<jsp:param name="gid" value="1220" />
</jsp:forward>
And with that, it's about time to call this a wrap. We hope
you enjoyed it, and that it served as a good starting point for your entry into the world of JSP.
If you're interested in learning more about the topics discussed in this series, take a look at Sun Microsystems' JSP pages at http://java.sun.com/products/jsp/, Java documentation and references at http://java.sun.com/docs/, or the tutorial on tag libraries at http://java.sun.com/products/jsp/tutorial/TagLibrariesTOC.html. If, on the other hand, you have questions, comments, or large sums of money for us, drop us a line - we'd love to hear from you!
Until next time...stay healthy! | DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
|