Home arrow Java & J2EE arrow Page 7 - The JSP Files (part 7): Bugs, Beans And Banks

Turning Up The Heat - Java

In this week's episode, find out how the JSP Exception objectprovides developers with a graceful way to recover from script errors. Andthen take a quick tour of the JSP directives you need to know in order tointegrate standalone JavaBeans into your JSP scripts.

TABLE OF CONTENTS:
  1. The JSP Files (part 7): Bugs, Beans And Banks
  2. Bugathon
  3. Exceptionally Clever
  4. Bad News
  5. You Throw(), I'll Catch
  6. Bean Bag
  7. Turning Up The Heat
By: Vikram Vaswani and Harish Kamath, (c) Melonfire
Rating: starstarstarstarstar / 2
April 18, 2001

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
In order to illustrate how this works, we've written a simple Bean which accepts temperature values and converts them between Celsius and Fahrenheit scales. Here it is:

temperature.zip

And here's a page which uses it:

<html> <head> <basefont face="Arial"> </head> <body> <!-- initialize the Bean, set some defaults --> <jsp:useBean id="c" scope="page" class="Temperature"> <jsp:setProperty name="c" property="celsius" value="10" /> </jsp:useBean> <% // get the current temperature out.println("Temperature in Celsius is " + c.getCelsius() + "<p>"); // turn up the heat c.setCelsius(36.8); // get the current temperature out.println("Temperature in Celsius is now " + c.getCelsius() + "<p>"); // convert the temperature to Fahrenheit out.println(c.getCelsius() + " Celsius is " + c.convertCelsiusToFahrenheit(c.getCelsius()) + " Fahrenheit<p>"); // ...and back again out.println(c.getFahrenheit() + " Fahrenheit is " + c.convertFahrenheitToCelsius(c.getFahrenheit()) + " Celsius<p>"); %> </body> </html>

And here's the output:

Temperature in Celsius is 10.0 Temperature in Celsius is now 36.8 36.8 Celsius is 98.24 Fahrenheit 98.24 Fahrenheit is 36.8 Celsius

And that's about it for the moment. In the next - and final - article in this series, we'll be exploring JSP's tag libraries, which allow Web designers to add powerful funtionality to their Web pages without knowing JSP. Make sure you make it out here for that one!

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

blog comments powered by Disqus
   

JAVA & J2EE ARTICLES

- 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
- Java EE 7 Looks to the Cloud
- Oracle Seeks Billions from Google Over Patent
- Oracle Java 6 Update Fixes Security Vulnerab...
- RIM Releases New BlackBerry Java SDK
- Oracle Now Offering JRockit for Free
- Google App Engine Includes Java Backend


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 6 - Follow our Sitemap

Dev Shed Tutorial Topics: