Articles Section Index | Page 5
Basic structure of an applet
Well, this is very simple and the basic structure of an applet will be the same for every applet you will program. The major difference between an applet and an application is that there is no publ...more
Files and Directories in Java
Java contains a lot of useful utility packages. One is java.util with its lists, maps, and calendar stuff--a lot to look into and use in your applications. Another package, java.io, contains what y...more
Files and Directories in Java | Directory Structure
For testing our programs we need a simple directory structure, with a few files and a few directories. Something along the lines of this:
Files and Directories in Java | HTML Output
Outputting results to System.out is not actually cutting edge technology, so let's consider showing the directory structure in some other formats. In the first one we'll present the output as an HT...more
Files and Directories in Java | The MyDir Class
The class for the directory is also rather simple, but this class also has to keep track of the files and directories it contains. Let's use two Vectors for this purpose. Since the code is so simpl...more
Files and Directories in Java | XML Output
If you show this jsp-file in an XML-aware browser like Microsoft Internet Explorer 5.5 you'll get this picture:
Java Exception Classes | Formatting Routines
One of the advantages of using your own exception class is that you can format the data and the trace back like you want it.
Java Exception Classes | Linking the Classes
One of the things which are saved in our exception class is the exception it has just caught. By doing this we'll get a linked list of exception classes, that can document the calling sequence "top...more
Unit Testing Java Programs
Testing programs can be very boring. Especially testing other people's programs. And especially if you're a programmer. But programmers love to write programs, so why not let the programmers write ...more
Unit Testing Java Programs | Collecting Test Cases
During the development of a web-project you'll build more and more test cases, which all may be run individually, but often you'll want to run more or all of them in one go.
Unit Testing Java Programs | Junit
JUnit is a Java open source project which offers an extremely useful framework for unit testing.
Unit Testing Java Programs | The Round Class
For the Round class we'll need a method--newScore--to enter the strokes for the hole we've just played. To get the current score we define a method called currentScore.
Writing Servlet Filters
Filters are an under-appreciated feature of the Java servlet platform, ideal for writing components that can be added transparently to any web application. A filter is like a lightweight servlet th...more
Writing Servlet Filters | Redirecting a Request
Another use for filters is to restrict access to resources - if a filter doesn't call FilterChain.doFilter(), the resource won't be loaded. Simply returning would send an empty document to the brow...more
Writing Servlet Filters | The Filter Mapping Block
Now we need to tell the servlet container when to apply the filter, which is done with a block. The filter-mapping block includes the filter-name, which must match the name given in a block, and ...more