JSP / CATATAN</>↗JSP06 Mei 2008
This example show you how to obtain web application context path in JSP using Expression Language (EL) feature of JSP. To get the context path we can utilize the pageContext, it is an implicit object that available on every JSP pages. From this object you can get access to various object such as: servletContext session […]
SERVLET / CATATAN</>↗Servlet03 Mei 2008
The context path always comes first in a request URI. The path starts with a “/” character but does not end with a “/” character. When I have a web application with the URL like http://localhost:8080/myapp` then/myapp` is the context path. For servlets in the default (root) context, this method returns "" (empty string). package […]
CORE API / CATATAN</>↗Core API28 Apr 2008
This example demonstrates how to copy file using the Java IO library. Here we will use the java.io.FileInputStream and it’s tandem the java.io.FileOutputStream class. package org.kodejava.io; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class FileCopyDemo { public static void main(String[] args) { // Create an instance of source and destination files File source […]
CORE API / CATATAN</>↗Core API24 Apr 2008
The System.clearProperty(String key) method enables you to remove a system property. The key must not be an empty string or a null value because it will cause the method to throw an IllegalArgumentException or a NullPointerException. It will also check if a SecurityManager exists and if you don’t have a write permission to the system […]
SWING / CATATAN</>↗Swing20 Apr 2008
This example show you how to handle JFrame window events such as windowOpened, windowClosing, windowClosed, etc. For handling these events we need to add a WindowListener listener to the JFrame instance. Here we use the WindowAdapter abstract class and implement the method which event we want to handle. package org.kodejava.swing; import javax.swing.JFrame; import javax.swing.SwingUtilities; import […]
CORE API / CATATAN</>↗Core API15 Apr 2008
Creating a program to be run on more than one platform such as Windows and Linux our program need to understand the difference between both platform. The simplest thing for instance is the file separator. Windows use "\" (backslash) while Linux use "/" (forward slash). To avoid manual checking for the operating system we can […]