Tag: Java

Applet that uses processXxx methods to print detailed reports on mouse events. Illustrates low-level alternative to handling events with listeners.

import java.applet.Applet; import java.awt.*; import java.awt.event.*; /** Prints non-detailed reports of mouse events.  *  Uses the low-level processXxxEvent methods instead  *  of the usual event listeners.  *    ***************** public class MouseReporter extends Applet {   public void init() {     setBackground(Color.blue); // So you can see applet in page     enableEvents(AWTEvent.MOUSE_EVENT_MASK |                  AWTEvent.MOUSE_MOTION_EVENT_MASK); …

Continue reading

HeadingExample.jsp Page that uses the HeadingTag custom tag

HeadingExample.jsp Page that uses the HeadingTag custom tag <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”> <!– Illustration of HeadingTag tag. Taken from Core Web Programming Java 2 Edition from Prentice Hall and Sun Microsystems Press, . May be freely used or adapted. –> <HTML> <HEAD> <TITLE>Some Tag-Generated Headings</TITLE> </HEAD> <BODY> <%@ taglib uri=”cwp-taglib.tld” prefix=”cwp” %> …

Continue reading

PrimeExample.jsp Page that uses the PrimeTag custom tag

PrimeExample.jsp Page that uses the PrimeTag custom tag <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”> <!– Illustration of PrimeTag tag. Taken from Core Web Programming Java 2 Edition from Prentice Hall and Sun Microsystems Press, . May be freely used or adapted. –> <HTML> <HEAD> <TITLE>Some N-Digit Primes</TITLE> <LINK REL=STYLESHEET       HREF=”JSP-Styles.css”       TYPE=”text/css”> </HEAD> …

Continue reading

SimplePrimeExample.jsp Page that uses the SimplePrimeTag custom tag

SimplePrimeExample.jsp Page that uses the SimplePrimeTag custom tag <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”> <!– Illustration of SimplePrimeTag tag. Taken from Core Web Programming Java 2 Edition from Prentice Hall and Sun Microsystems Press, . May be freely used or adapted. –> <HTML> <HEAD> <TITLE>Some 50-Digit Primes</TITLE> <LINK REL=STYLESHEET       HREF=”JSP-Styles.css”       TYPE=”text/css”> </HEAD> …

Continue reading

SimpleExample.jsp Page that uses the ExampleTag custom tag.

SimpleExample.jsp Page that uses the ExampleTag custom tag. <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”> <!– Illustration of very simple JSP custom tag. Taken from Core Web Programming Java 2 Edition from Prentice Hall and Sun Microsystems Press, . May be freely used or adapted. –> <HTML> <HEAD> <%@ taglib uri=”cwp-taglib.tld” prefix=”cwp” %> <TITLE><cwp:example /></TITLE> …

Continue reading

ExampleTag.java Very simple custom tag. Remember to install it in the WEB-INF/classes/cwp/tags directory.

ExampleTag.java Very simple custom tag. Remember to install it in the WEB-INF/classes/cwp/tags directory. package cwp.tags; import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; import java.io.*; /** Very simple JSP tag that just inserts a string  *  (“Custom tag example…”) into the output.  *  The actual name of the tag is not defined here;  *  that is given by the …

Continue reading

AccessCountBean.java Bean used to illustrate the difference between running jsp:setProperty for every request vs. only when the object is created

AccessCountBean.java Bean used to illustrate the difference between running jsp:setProperty for every request vs. only when the object is created 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 …

Continue reading

SaleEntry2.jsp Page that uses the SaleEntry bean, using the param attribute to read request parameters and assign them to bean properties

SaleEntry2.jsp Page that uses the SaleEntry bean, using the param attribute 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 an explicity association with an input parameter. See SaleEntry1.jsp and SaleEntry3.jsp for alternatives.     Taken from Core Web Programming Java …

Continue reading

SaleEntry.java Bean used to demonstrate the various approaches to reading request parameters and stuffing them into Java objects.

package cwp; /** Simple bean to illustrate the various forms  *  of jsp:setProperty.  *  <P>  *  Taken from Core Web Programming Java 2 Edition  *  from Prentice Hall and Sun Microsystems Press,  *  .  *  May be freely used or adapted.  */ public class SaleEntry {   private String itemID = “unknown”;   private double …

Continue reading

The class that actually gets the strings over the network by means of an ObjectInputStream via HTTP tunneling.

import java.net.*; import java.io.*; /** When this class is built, it returns a value  *  immediately, but this value returns false for isDone  *  and null for getQueries. Meanwhile, it starts a Thread  *  to request an array of query strings from the server,  *  reading them in one fell swoop by means of an …

Continue reading