How to use Tuckey UrlRewriteFilter

A nicely designed url structure is very crucial for any web application.Its worth to take some time to design it before the development.

How Tomcat manage session data

Session is an identifier that represent the login status of a visitor. Session usually implemented by cookie, for example, in PHP, a special cookie named as "PHPSESSION_XXXX" was sent to browser and back to server every time user visit a page, thus the server can track the user between different pages.

Using jStyleParser to extract part of a web page

jStyleParser is a Java library that can parse the css rule of the web page and assign to respond DOM element. With this tool , we can extract part of a HTML page and maintain it's looks and style.

In this post , I will illustrate how to do this.

A Simple Ant Example

Ant is a build tool for Java project. In this post I will introduce a very simple ant build file.

For a classic Java project, there are java source files and jar libraries. Usually the java source file reside in src directory, libraries reside in lib directory.

Java traverse a directory and zoom image files

In this example, the code list all the files in a directory and zoom the images into fixed width.

You need these jars:

Java generics Wildcards

The syntax <? extends T> is "any type that is subtype of T".

The list might might be any list that contains subtype of Number. So next code would be wrong.

Java Generics Introduction

The Java Generics is much like the C++ template. But they are also very different from each other.

A simple exampe:

How to download gziped web pages with Java

The common way to do this is detect Content-Encoding Http header field, if it exist and value is "gzip", using GZIPInputStream to wrap the InputStream.

But the Content-Encoding is not always reliable, some pages output gzip compressed data without Content-Encoding field set.

Java Mysql Example

MySQL is an Open Source database system, its fast and light weight. MySQL is a very good choice for small to medium size project. It can work with all kinds of platform and languages. This tutorial shows how to work with MySQL in Java.

To use MySQL in Java, we have to get the JDBC driver for MySQL. JDBC is a specification of how to generally access a database. Different database vendor should provide a bridge that connect the specific database implementation and JDBC API. Such a bridge is also called driver or connector.

To use MySQL in Java, we have to get the JDBC driver for MySQL. JDBC is .

Java Volatile keywords

When multiple thread access the same object concurrently , there are two methods to do it: access the original object every time or keep a local private copy of the object. The second way surely faster because access shared memory need some extra works.

But there is a problem: what if the original object changed? In other words, the second method may cause shared variable inconsistent. But for some shared variables , we only read it, never change it or occasionally change it, under this circumstance , its safe to use private local copy and gain the performance.

But there is a problem: what if the original object changed? In other words, the second method .

Previous Page 1 ... 21 22 23 Next Page