March 7, 2003

Set Attributes in a Servlet Request

Usually, you set attributes in a session and the attributes are available through out the session. If you want to limit the scope of an attribute to just a request, you can set the attributes on a request object. This is how: request.setAttribute(“attributeName”,attributeValue);attributeName – This is a string , the

Use the Deprecation Tag to Warn of Code Changes

When you need to change the parameters or name of a class or method you developed use the javadoc @deprecated tag and leave the old code. This allows other to be warned that they need to update their code without having to break a build process.The following code illustrates its

The Beans Class

The standard Java library contains a host of valuable methods. Many of these are hidden away, such as Beans.isInstanceOf.This method belongs to the java.beans.Beans class. However, it’s an object version of the instanceof keyword and is far more generic than the simple Java Bean standard.The instanceof keyword is used to

Implement Property File Attributes in Real Time

Say you need to change the behavior of your Java application depending on some parameters read from a properties or ini file (like batchMode, debugMode, etc.). You want to turn one of those switches (parameters) on or off

Loading from the Classpath

If your application includes .properties files or images and you want to load them without hard-coding their location, store the files in the class path. Classes are stored in archive files (.jar or .zip) or directories. Loading them is easy. Here’s how: import java.awt.Toolkit;import java.awt.Image;import java.io.InputStream;import java.io.IOException;import java.net.URL;import java.util.Properties;public class