Home arrow Java & J2EE arrow Page 6 - The JSP Files (part 8): Tagged And Bagged

Applet Antics - Java

One of the most exciting features about JSP is the ability tobuild and use custom "tag libraries" in your JSP applications. In thisarticle, find out why tag libraries are a Good Thing, and read about how toget and install custom tag libraries for common tasks.

  1. The JSP Files (part 8): Tagged And Bagged
  2. Playing Tag
  3. Looking Inside
  4. Meeting Popeye
  5. You've Got Mail!
  6. Applet Antics
By: Vikram Vaswani and Harish Kamath, (c) Melonfire
Rating: starstarstarstarstar / 5
June 11, 2001

print this article


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!

>>> More Java & J2EE Articles          >>> More By Vikram Vaswani and Harish Kamath, (c) Melonfire

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- More Java Bugs Lead to More Attacks
- Oracle's Java One Brings News, Surprises
- Oracle Patches Java Runtime Environment
- Apple Syncs Java Update with Oracle
- Spring 3.1 Java Development Framework Compat...
- Jelastic Java PaaS Availability and Pricing ...
- NetBeans 7.1 Released, Supports JavaFX 2
- SolarWinds Releases Newest Version of Java M...
- Free Monitoring Tool for Java Apps on Heroku
- Heroku Adds JCloud Platform Support, Java 7 ...
- Java SE 8 Speculation in Full Swing
- Java SE 7 Now Available
- New JVM Language and Java Reporting Tool
- Java 7 Release Update and New Eclipse Toolkit
- The Best Java Netbeans IDE Plugins

Developer Shed Affiliates


Dev Shed Tutorial Topics: