Category: Root

UrlRetriever.java Accepts an URL from the command line, parses the host, port, and URI components from the URL and then retrieves the document. Requires the following classes

UrlRetriever.java  Accepts an URL from the command line, parses the host, port, and URI components from the URL and then retrieves the document. Requires the following classes: import java.util.*; /** This parses the input to get a host, port, and file, then  *  passes these three values to the UriRetriever class to  *  grab the …

Continue reading

AddressVerifier.java Connects to an SMTP server and issues a expn request to display details about a mailbox on the server. Uses the following classes

import java.net.*; import java.io.*; /** Given an e-mail address of the form user@host,  *  connect to port 25 of the host and issue an  *  ‘expn’ request for the user. Print the results.  *  *  Taken from Core Web Programming from  *  Prentice Hall and Sun Microsystems Press,  *  .  *  © 2001 Marty Hall …

Continue reading

Buggy Counter Applet.java Demonstrates that data shared by multiple threads is candidate for a potential race condition

import java.applet.Applet; import java.awt.*; /** Emulates the Counter and Counter2 classes, but this time  *  from an applet that invokes multiple versions of its own run  *  method. This version is likely to work correctly  *  except when  an important customer is visiting. public class BuggyCounterApplet extends Applet                                 implements Runnable{   private int totalNum …

Continue reading

SplitTest.java Illustrates parsing a string with a String.split

SplitTest.java Illustrates parsing a string with a String.split /** Prints the tokens resulting from treating the first * command-line argument as the string to be tokenized * and the second as the delimiter set. Uses * String.split instead of StringTokenizer. */ public class SplitTest { public static void main(String[] args) { if (args.length == 2) …

Continue reading

TokTest.java Illustrates parsing a string with a StringTokenizer.

TokTest.java  Illustrates parsing a string with a StringTokenizer. import java.util.StringTokenizer; /** Prints the tokens resulting from treating the first  *  command-line argument as the string to be tokenized  *  and the second as the delimiter set.  *  *  Taken from Core Web Programming from  *  Prentice Hall and Sun Microsystems Press,  *  .  *  © …

Continue reading

কীবোর্ড থেকে একটি কী হারিয়ে গেলে বা নষ্ট হয়ে গেলে কি করবেন?

আপনার ল্যাপটপের একটি বা একাধিক কী হারিয়ে গেছে বা নষ্ট হয়ে গেছে এবং আপনি জানেন না এখন কি করবেন? ভয় পাবার কিছু নেই, সম্ভবত আপনি কীবোর্ডটি ঠিক করতে পারবেন এবং নতুন একটি কীবোর্ড ক্রয় করার কোন প্রয়োজন হবে না। সকল কীবোর্ড এর জন্য অনন্য সমাধান নেই, কারণ সকল কীবোর্ড এক নয়। এখানে সাধারণ ক্ষেত্রে কি …

Continue reading

NetworkClientTest.java Makes a simple connection to the host and port specified on the command line. Uses the following classes

NetworkClientTest.java  Makes a simple connection to the host and port specified on the command line. Uses the following classes: /** Make simple connection to host and port specified.  *  *  Taken from Core Web Programming from  *  Prentice Hall and Sun Microsystems Press,  *  .  *  © 2001 Marty Hall and Larry Brown;  *  may …

Continue reading

ShowSession.java Servlet that uses session tracking to determine if the client is a repeat visitor. Uses the ServletUtilities class to simplify the DOCTYPE and HEAD output.

ShowSession.java Servlet that uses session tracking to determine if the client is a repeat visitor. Uses the ServletUtilities class to simplify the DOCTYPE and HEAD output. package cwp; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.net.*; import java.util.*; /** Simple example of session tracking. * * Taken from Core Web Programming Java 2 Edition * …

Continue reading

LongLivedCookie.java Subclass of Cookie that automatically sets the max age to one year.

LongLivedCookie.java  Subclass of Cookie that automatically sets the max age to one year. package cwp; import javax.servlet.http.*; /** Cookie that persists 1 year. Default Cookie doesn’t  *  persist past current session.  *    *  Taken from Core Web Programming Java 2 Edition  *  from Prentice Hall and Sun Microsystems Press,  *  .  *  May be …

Continue reading

ShowCookies.java Servlet that displays all cookies that arrived in current request. Uses the ServletUtilities class.

ShowCookies.java Servlet that displays all cookies that arrived in current request. Uses the ServletUtilities class. package cwp; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; /** Sets six cookies: three that apply only to the current * session (regardless of how long that session lasts) * and three that persist for an hour (regardless of * whether …

Continue reading