November 19, 1998

Reflecting on a Classy String

Java’s reflection API allows the instantiation of an object using only its String description. A Java application can determine the class of an object from the associated string and then construct an instance of the class. For example: public Object getObject (){ try { Class MyClass = Class.forName(“Hello”); Constructor con

Declaring a Construct as Final Simplifies Optimizations

In Java, the keyword final qualifies a construct (class, variable, or method) that may not be changed or overridden. Qualifying a variable as final ensures that the variable may not be assigned another value. Qualifying a class as final ensures that it is a leaf class?for example, it cannot be

Putting out the Trash Using the gc() Call

The gc() call on the Java Virtual Machine’s garbage collector is often misunderstood. One of the reasons Java is such an easy language to program in is that it takes the burden of memory management away from the developer. Specifically, you never have to worry about deallocating memory that is

Efficient Use of the Vector Class

The Vector class in java.util is one of the most frequently used classes in Java development. It almost makes the problem of memory management non-existent, unlike a fixed-size array. However, using this class doesn’t come without a cost. At instantiation, a Vector object allocates memory for 10 object references by

Define Background, Text, and Link Colors to Avoid Whiteouts

It’s easy to change the background color of your page, but if you don’t also define the foreground color and link colors, it’s likely that some users will not be able to view your page. Inevitably there are users who set their browser page foregrounds and backgrounds to use unusual

Add a MIME Type to IIS 4

When you want to serve up a new type of file that Microsoft’s Internet Information Server (IIS) does not recognize, you need to add a MIME type. With older versions of IIS this was done manually using the Registry Editor. Fortunately it is a lot easier with IIS version 4.

Revive Forms That Break When Inserted Into a Table

Many times a form that works perfectly well on a table-less Web page stops working when inserted into a table cell. To make the form work again, move the and tags so that they span the tags, as shown in the following HTML code: Spam Removal Form Enter full name

Make Your Cookies Live Longer

When using ASP to create browser cookies, by default the cookie is alive only as long as the browser is running. You can make cookies last longer by defining an expiration date at the same time you bake the cookie. Note that since the user might be anywhere on the

No more posts to show