Category: Java/J2EE/J2ME

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

A class the encapsulates the URLs used by various search engines.

SearchSpec.java ******************* /** Small class that encapsulates how to construct a  *  search string for a particular search engine.  *  Taken from Core Web Programming Java 2 Edition  *  from Prentice Hall and Sun Microsystems Press,  *  May be freely used or adapted.  */ public class SearchSpec {   private String name, baseURL, numResultsSuffix;   …

Continue reading

DebugExample.jsp Page that uses the DebugTag custom tag

# DebugExample.jsp Page that uses the DebugTag 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>Using the Debug Tag</TITLE> <LINK REL=STYLESHEET       HREF=”JSP-Styles.css”       …

Continue reading