1. OSCache – OSCache is a caching solution that includes a JSP tag library and set of classes to perform fine grained dynamic caching of JSP content, servlet responses or arbitrary objects. It provides both in memory and persistent on disk caches, and can allow your site to have graceful error tolerance (eg if an error occurs like your db goes down, you can serve the cached content so people can still surf the site almost without knowing).

2. JBoss Cache – JBoss Cache still is, as it’s name suggests, a cache. It is a product designed to cache frequently accessed Java objects in order to dramatically improve the performance of applications. This makes it easy to remove data access bottlenecks – such as connecting to a database.
And unlike non-cluster-aware caches which may go out of sync when there are concurrent updates, each JBoss Cache instance is aware of remote cache updates and can either invalidate or update it’s state.

3. cache4j – cache4j is a cache for Java objects with a simple API and fast implementation. It features in-memory caching, a design for a multi-threaded environment, both synchronized and blocking implementations, a choice of eviction algorithms (LFU, LRU, FIFO), and the choice of either hard or soft references for object storage.

4. Ehcache – Ehcache is a widely used java distributed cache for general purpose caching, Java EE and light-weight containers.

It features memory and disk stores, replicate by copy and invalidate, listeners, cache loaders, cache extensions, cache exception handlers, a gzip caching servlet filter, RESTful & SOAP APIs, an implementation of JSR107 and much more…
Read more

Post to Twitter Post to Yahoo Buzz Post to Delicious Post to Digg Post to Reddit Post to StumbleUpon

Share or Bookmark This Post With :

Monitor4Tomcat – is a set of scripts that can be used to restart Tomcat when exceptions or other errors have occurred in the application.
These scripts can help your Apache Tomcat application to continue to run in the face of OutOfMemory exceptions or other un-expected exceptions.

The script will check for OutOfMemory exceptions in the logs and sample pages from tomcat to make sure the application is servicing requests.

If a problem occurs the monitor can stop / start the tomcat JVM and / or the entire application.

The monitor requires bash and perl to run. It should run in most reasonable Linux / UNIX environments.

Post to Twitter Post to Yahoo Buzz Post to Delicious Post to Digg Post to Reddit Post to StumbleUpon

Share or Bookmark This Post With :

10
Oct

First download Apache Jakarta Commons FileUpload library from this link and add into classpath of your Application.

Validate HTTP Request

Now that you have installed the FileUpload library, you can start writing the code. First, we have to make sure the HTTP request is encoded in multipart format. This can be done using the static method isMultipartContent() of the ServletFileUpload class of the org.apache.commons.fileupload.servlet package:

if (ServletFileUpload.isMultipartContent(request)){
// Parse the HTTP request…
}

In the above Java code snippet, request is a javax.servlet.http.HttpServletRequest object that encapsulates the HTTP request.

Parsing Form Data

Second, we will parse the form data contained in the HTTP request. Parsing the form data is very straightforward with the Apache Jakarta Commons FileUpload library:

ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory());
List fileItemsList = servletFileUpload.parseRequest(request);

(In the above Java code snippet, DiskFileItemFactory is a class contained in the org.apache.commons.fileupload.disk package and List is an interface contained in the java.util package.)

If everything works fine, fileItemsList will contain a list of file items that are instances of FileItem of the org.apache.commons.fileupload package. A file item may contain an uploaded file or a simple name-value pair of a form field.

By default, the ServletFileUpload instance created by the above Java code uses the following values when parsing the HTTP request:

  • Size threshold = 10,240 bytes. If the size of a file item is smaller than the size threshold, it will be stored in the memory. Otherwise it will be stored in a temporary file on disk.
  • Maximum HTTP request body size = -1, which means the server will accept HTTP request bodies of any size.
  • Repository = System default temp directory, whose value can be found by the Java code System.getProperty(“java.io.tmpdir”). Temporary files will be stored there.

If you do not like the default settings, you can change them using the methods setSizeThreshold() and setRespository() of the DiskFileItemFactory class and the setSizeMax() method of the ServletFileUpload class, like this:

DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory();
diskFileItemFactory.setSizeThreshold(40960); /* the unit is bytes */

File repositoryPath = new File(“/temp”);
diskFileItemFactory.setRepository(repositoryPath);

ServletFileUpload servletFileUpload = new ServletFileUpload(diskFileItemFactory);
servletFileUpload.setSizeMax(81920); /* the unit is bytes */

If the size of the HTTP request body exceeds the maximum you set, the SizeLimitExceededException exception (fully qualified name: org.apache.commons.fileupload.FileUploadBase.SizeLimitExceededException) will be thrown when you call the parseRequest() method:

try {
List fileItemsList = servletFileUpload.parseRequest(request);
/* Process file items… */
}
catch (SizeLimitExceededException ex) {
/* The size of the HTTP request body exceeds the limit */
}

Read more

Post to Twitter Post to Yahoo Buzz Post to Delicious Post to Digg Post to Reddit Post to StumbleUpon

Share or Bookmark This Post With :

   « Older Entries
Subscribe to RSS Feeds Follow me on Twitter Add to Favourite
 
Sponsors
 
Tags
 
Network [+]
 
© Copyright 2009 - 2011 TechiePark.com. All Rights Reserved | Powered by WordPress
This work is licensed under a Creative Commons Attribution 3.0 Unported License
Php5 powered    Mysql powered    Apache powered   Best viewed with  Spread Firefox Affiliate Button