Category: Java/J2EE/J2ME

cwp-taglib.tld Tag Library Descriptor file used by the custom tags in this chapter.

cwp-taglib.tld Tag Library Descriptor file used by the custom tags in this chapter. <?xml version=”1.0″ encoding=”ISO-8859-1″ ?> <!DOCTYPE taglib  PUBLIC “-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN”  “http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd”> <!– a tag library descriptor –> <taglib>   <!– after this the default space is         “http://java.sun.com/j2ee/dtds/jsptaglibrary_1_2.dtd”    –>   <tlibversion>1.0</tlibversion>   <jspversion>1.1</jspversion>   <shortname>cwp</shortname>   <!– …

Continue reading

SharedCounts1.jsp, SharedCounts2.jsp, and SharedCounts3.jsp Three pages that all use the AccessCountBean. Results you get depend on which page is hit first and how many total hits the combined pages receive.

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”> <!– Example of sharing beans. Taken from Core Web Programming Java 2 Edition from Prentice Hall and Sun Microsystems Press, . May be freely used or adapted. –> <HTML> <HEAD> <TITLE>Shared Access Counts: Page 1</TITLE> <LINK REL=STYLESHEET       HREF=”JSP-Styles.css”       TYPE=”text/css”> </HEAD> <BODY> <TABLE BORDER=5 ALIGN=”CENTER”>   <TR><TH …

Continue reading

SaleEntry3.jsp Page that uses the SaleEntry bean, using property=”*” to read request parameters and assign them to bean properties

SaleEntry3.jsp Page that uses the SaleEntry bean, using property=”*” to read request parameters and assign them to bean properties <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”> <!– Example of using jsp:setProperty and a general association with the input parameters. See SaleEntry1.jsp and SaleEntry2.jsp for alternatives.     Taken from Core Web Programming Java 2 Edition …

Continue reading

SaleEntry1.jsp Page that uses the SaleEntry bean, using explicit Java code to read request parameters and assign them to bean properties.

SaleEntry1.jsp Page that uses the SaleEntry bean, using explicit Java code to read request parameters and assign them to bean properties.   <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”> <!– Example of using jsp:setProperty with an explicit value supplied to the “value” attribute. See SaleEntry2.jsp and SaleEntry3.jsp for alternatives. Taken from Core Web Programming Java …

Continue reading

StringBean.jsp Page that manipulates the StringBean bean with both jsp:useBean (i.e., XML-style) syntax

StringBean.jsp Page that manipulates the StringBean bean with both jsp:useBean (i.e., XML-style) syntax package cwp; /** Simple bean to illustrate sharing beans through  *  use of the scope attribute of jsp:useBean.  *  <P>  *  Taken from Core Web Programming Java 2 Edition  *  from Prentice Hall and Sun Microsystems Press,  *  .  *  May be …

Continue reading

RepeatTag.java Custom tag that repeats the tag body a specified number of times

RepeatTag.java Custom tag that repeats the tag body a specified number of times package cwp.tags; import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; import java.io.*; /** A tag that repeats the body the specified  *  number of times.  *  <P>  *  Taken from Core Web Programming Java 2 Edition  *  from Prentice Hall and Sun Microsystems Press,  *  . …

Continue reading

An applet that reads arrays of strings packaged inside a QueryCollection and places them in a scrolling TextArea.

import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.net.*; /** Applet reads arrays of strings packaged inside  *  a QueryCollection and places them in a scrolling  *  TextArea. The QueryCollection obtains the strings  *  by means of a serialized object input stream  *  connected to the QueryGenerator servlet.  *    *  Taken from Core Web Programming …

Continue reading

FilterTag.java Custom tag that modifies the tag body

FilterTag.java Custom tag that modifies the tag body package cwp.tags; import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; import java.io.*; import cwp.*; /** A tag that replaces <, >, “, and & with their HTML  *  character entities (<, >, “, and &).  *  After filtering, arbitrary strings can be placed  *  in either the page body or in …

Continue reading

An applet that searches multiple search engines, displaying the results in side-by-side frame cells.

Using Applets as Front Ends to Server-Side Programs ************************************************** SearchApplet.java An applet that searches multiple search engines,  displaying the results in side-by-side frame cells. Uses the following files: SearchSpec.javaParallelSearches.htmlSearchAppletFrame.htmlGoogleResultsFrame.htmlInfoseekResultsFrame.htmlLycosResultsFrame.html *************************************************** // import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.net.*; // /** An applet that reads a value from a TextField,  *  then uses it to …

Continue reading

RotationExample.java An example of translating and rotating the coordinate system prior to drawing

import java.awt.*; /** An example of translating and rotating the coordinate  *  system before each drawing.  *  ******************************* public class RotationExample extends StrokeThicknessExample {   private Color[] colors = { Color.white, Color.black };   public void paintComponent(Graphics g) {     clear(g);     Graphics2D g2d = (Graphics2D)g;     drawGradientCircle(g2d);     drawThickCircleOutline(g2d);     // Move the origin …

Continue reading