Before you start
This tutorial is written for developers who want to implement some form of browser detection APIs in their applications. You can use Geronimo as a java™2 Platform Enterprise Edition Application server (especially using Jetty as a servlet container) and some client-side JavaScript. You will develop several separate java-based components, including a servlet filter and two custom JSP tags. You will use Apache ant as the compilation tool to build the. war file, which can be deployed into Geronimo, so it helps if you are familiar with Ant. You should be familiar with the concepts of filters and JSP tag libraries, and you can easily read Java source code.
At the end of this tutorial, you should learn how to develop your own basic servlet filters and JSP tag libraries, and you can use the Apache Geronimo application Server to implement a robust browser detection API in the Java EE program.
About this tutorial
The content of this tutorial may avoid some of the real questions, "Why use another browser detection tool?" ", or" why not use Browserhawk or other products on the market? "Sometimes it's best to develop a tool from scratch when a product doesn't meet your requirements or is not easy to integrate with your application." In addition, many tools (including Browserhawk) are proprietary tools, which does not mean a bad thing; however, some developers prefer to use more open tools, so they can easily adjust these tools to meet their special needs. Geronimo is a good example. The Apache Software Foundation wants to provide a fully open Java EE Application Server to meet some of the requirements that are not yet met in the developer community. The reason for this is not that there is no good Java Java Application Server at the moment, but because Apache wants to build an open source, certified EE server that can be supported by the developer community.
The techniques used in this tutorial are not only related to browser and OS detection, but the same technology can also be used to detect the Macromedia Flash version installed on the client or in which country the client is located. There are open source JavaScript programs that provide access to this information, and these scripts are available for the same technology currently used to detect browsers and OS.
The structure of this tutorial is as follows:
Custom JSP tags-This is a review that provides a brief overview of what custom JSP tags and tag libraries are, and how to develop JSP tags and tag libraries.
The JavaScript overview used for browser detection describes the reasons for selecting JavaScript for browser detection and its role in the application.
Design strategies give you a general idea of how to design this sample application and eventually deploy to a compiled structure in Geronimo.
Server-side Components detail the source code in all server-side Java components and sample applications, and combine them to interact with each other.
The JSP component and the sample application detail the JSP components used in the application and provide several examples of how to use custom tags developed in this application.
The experiment allows you to start compiling and building this sample program from the source code, and provides the commands needed to deploy the application to Geronimo and test the application's functionality.
Prerequisite conditions
This tutorial assumes that you have a basic understanding of the Java Servlet API and the Java programming language. Knowledge of JavaScript is also possible.
System needs
To run the sample code in this tutorial, you need to perform the following steps:
Download and install the following application:
Geronimo Milestone 4 or newer version.
Apache ANT 1.6.5.
J2SE 1.4.2_09.
Make sure that the environment variables that are summarized in table 1 are already defined in the shell.
Variable name |
The settings you want |
Geronimo_home |
Set to install the root directory of Geronimo |
Ant_home |
Set to install Ant's root directory |
Java_home |
Set to install Java root directory |
Project_home |
Set to the root directory of the Browserdetection application |
PATH |
Make sure Ant_home/bin is already in your path |