AJAX Geography Project
Display security logs geographical visualization and various geographical
data at the client side as much as possible
Simplify requirements from clients
Apache tomcat 6.0
Server side programming language
IP mapping database
Google charts API (
Mainly used technologies
HTML, DHTML, XML, JSON and AJAX.
All the server technologies used on both servers which were used in the project
In the process of development some
system architectures were implemented and
rejected due to the project constraints and difficulties which raised by technologies
The final system architecture consists of 2 servers:
On the both servers we have
evelopment environment but Local server does
not require specific environment (due to the project constraint).
implies two main roles:
Location of the HTML file, which is run by the user.
implies two main roles too:
Location of scripts that client side is using
The way the system works:
User opens a main HTML file on his local server. In this file we have a directive that
downloads a script from the global server that after
the downloading manages all
All data processing goes without page refresh by using AJAX (and AJAX like
technologies) and DHTML. For example we will describe the service “local group
the client choose this option on the screen (the o
ption will appear only after
registration of the service on global server
for each service and client pair we
have a data on the server that contains URL of the service and its transfer
technology) the request to the local server will be initiated. Reque
st will be for
the service “getLocalGroups”, the local server must return a list of the local
groups which exists on the server.
he application will have the list it will be displayed to the user for
choosing the group he wants to display.
a new request to the local server is initiated
now it will be for service “getLocalGroupData”. The service must return list of
IPs which the given group consists of.
When the list is available to the system, another request will be in
this time to the global server to “mapIP” service. This service provides us with
coordinates of the IP (here we use a MaxMind database).
When the coordinates are available they are displayed through Google Maps
API on the screen to the user
re are some more things in the process like for example determining if the IP
is a proxy or not, but we will not describe them here.
Now when we have a look on the systems lets describe the requirements from its
From the local server we require a w
eb server for 2 features:
Answering service requests
like we said, the local server must give us
some services examples of them are: “getLocalGroups”,
“getLocalGroupData” and so on.
These services are registred on the global
server. The data which the g
lobal server need to know about local (or
global) service is:
for which client the service is given
what service is given
from which url we may get the data
service transfer type
technology used to deliver the da
technology may be json, xml and plain text
other technologies may be added if needed (for example csv
or MS Excel file format)
mainly we use xml as default transfer type for the local server
Storing main HTML file
this file is the only thing we supply to the client.
The file is very simple in all manners:
There is some more lines that we need for the page to be a standard HTML
page but these are the main. The script we include is the main system
script and name is client name that we need to load the system
configuration for the given client
The requirements to the local server are that there will be a web server installed. We
o not need a special web server, or server side technology here. We need only to
store there the HTML page and get URLs from the server that will give us the data to
the client requests.
From the global
server we require a web server for 2 features
Answering service requests
like the local server the global server will answer
some request. We have seen some of them before in the example (“mapIP”)
there are others of course, mainly there are many parallel services given by
the local and global serv
ers. When the local server gives to the client local
picture, the global server will give approximate values for the picture. So by
comparing this pictures the system administrator will have an opportunity to
On the global server we store
the main scripts of the system, system
configuration, and data.
The global server administration is under our control, so here there will be more
requirements to the technology. For example all the services given by the global
server have transfer type “j
son”, because of cross domain security policy.
Save internal data at the client side as much as possible
The system architecture we implemented is using HTML page on the
clients server, so there is no data sent over the internet
request some service from the local server, so all the request to the
local server are safe.
There is no possibility to store all the data locally, so global requests are
no data is stored on the global server without user
The request results are not stored on the server, so if the
global server got hacked the user data will not be compromised (the
data stored in the clients networks and protected by the clients like they
want it to be protected).
Simplify requirements fro
There is only 1 requirement of the clients servers. They need to run a
web server, there is no requirement which web server they will use,
which database they use (if they use it at all). The system may run
without local requests at all, so the
user will only see the global
When user implements
we also simplified the process, he may
choose the technology for the data transfer
will he use JSON or XML
or any other implemented data transfer type (for example CSV may be
added to the system)
When the client implemented a new service it just need to be registered
in the database and the client will have the possibility to use the service.
There is no need to update anything by us on the client side.
Simplify update mec
The updates are simple to the user and to us. User do not need to do
anything. When he open the page the new version of the script will be
just loaded by the browser, and for us we just change the main script on
our web server. All the logic may be
simply changed. The data transfers
are not rely on the scripts so we may change the scripts without
changing the requests from the services that clients are implemented.
New services may be added, and when clients will want to add them
they will need onl
y to register the services
. If there is no
implementation of the new service for the client it will just not appear
as option on the clients page, there is no disruption in the system work.
The problems and solutions
For the first look the system
architecture is more complicated than most of the web
services that are implemented today. Let’s see why the standard ways to implement
web applications will not be applicable here and this will lead us to the solutions we
st years the web te
chnology consisted of 2 main parts: server and client when
the client side was passive and only provide the user interface. With evolution of
when the page may get the new dat
a without reloading of the page.
The simplest web architecture doesn’t give us the security, the data is on our server.
The client doesn’t know or may be doesn’t rely on our security. All the requests are
sent over the internet and may be intercepted. All
the data needed to be updated on
our server. If the client wants a new service we need to do code changes and client
need to deliver the data to us. So the architecture doesn’t give us the possibility to
fulfill the needed constraints.
If we use the new te
chnologies like AJAX with standard web architecture it from the
first look give us some solutions, but when trying to implement we will see
. Standard architecture assumes only 1 server. If we locate it in the client
network the updates will
be more than problematic, we will need to go to each
client and install the updates, the new services will require updates and so on. If we
locate it on our side of the network will still suffer from the security issues that were
The next step is to use two servers that will give us solution to the security issues,
but there are new problems
cross domain policies
here is no possibility to send
AJAX request to the domain other than a page’s.
So we can’t simply use 2 servers
AX will not work with one of them. And the second part of the new problems is
how we split the system logic to fulfill the constraints? If it will be on the client’s side
there will be problems with updates, and on our side will be problems with security.
So we placed the main page on the client
s side so the client may use AJAX requests
to his server
, all the logic are stored on the server but runs on the client so there is
no security issues, and there are simple updates because when we change the logic
the client will automatically get the new version. The requests to the global service
we do with AJAX like DHTML technology (we define a new dynamic script which is
requests needed data from our server). This technology overrides the cross domain
oblem because we may use scripts that are defined on other domains, like
for example we use Google Maps API.
Some words about services we use to give the needed possibilities. We needed
services to be imported:
IP mapping to coordinates.
inates to the map.
Each of these services is a system by itself
and implementation of these wasn’t our
goal. So, we needed to find an appropriate way to import them.
IP mapping to coordinates
here we choose MaxMind database.
very important for academic works.
ccuracy 99.3% on a country level
on a city
enough for our work.
It’s updated regularly
It may be downloaded to our server
we will know where the clients
going and it will not be sent to 3
It may be relatively simply imported into any database
given in CSV
Mapping coordinates to the map
we choose Google Maps service.
very important for academic works.
There is no ser
ver side logic needed
it’s very important because we
use static HTML page on the client side
we may add
to the map
our own markers
display icons and so on.
we choose Google charts API
No server side logic
There is no much possibilities but enough for us.
In the end all the constraints are fulfilled, and the system gives the possibilities we
The system installation
After installing all of the underlying technologies (tomcat, mys
ql, JSP), place the
project files to the appropriate places on web server. Files includes all the web files
and some JAVA classes (in our case IDE was integrated with tomcat so all the files
were placed automatically). Install provided database
image to my
command line or GUI tools that may be downloaded from official MySQL site).
In case of real use need only to put HTML page to the web server and configure the
client name in the global database.
In case of testing there is a need to
repeat the process with restoring DB image and
placing the project files to appropriate place on the server.
Updating MaxMind database
There is a monthly update to MaxMind IP locations DB. The install routine is:
Download CSV from
Create DB projserver
Create table by following code: CREATE TABLE `projserver`.`locations` (
`lid` int(10) unsigned NOT NULL auto_increment,
`country` char(2) NOT NULL,
2) NOT NULL,
`city` varchar(45) NOT NULL,
`pcode` varchar(45) NULL DEFAULT NULL,
`lat` float NOT NULL,
`long` float NOT NULL,
`mcode` varchar(45) NULL DEFAULT NULL,
`acode` varchar(45) NULL DEFAULT NULL,
PRIMARY KEY (`lid`)
Unpack the files into mysql DB directory
Enter the command line client from Querry browser
LOAD DATA INFILE 'loc.csv' INTO TABLE projserver.locations FIELDS TERMINATED BY ',' ENCLOSED BY '"'
ESCAPED BY '
' LINES TERMINATED BY '
IGNORE 2 LINES;
Remove not needed columns from the table
Create table by following code: CREATE TABLE `projserver`.`ipcity` (
`start` int(10) unsigned NOT NULL,
`end` int(10) unsigned NOT NULL,
`lid` int(10) unsigned NOT NULL default '0'
E=InnoDB DEFAULT CHARSET=latin1;
Enter command line
LOAD DATA INFILE 'ipcity.csv' INTO TABLE projserver.ipcity FIELDS TERMINATED BY ',' ENCLOSED BY '"'
ESCAPED BY '
' LINES TERMINATED BY '
n' IGNORE 2 LINES;
Services and clients configuration
There are 2
tables in the DB that needs to be update to add clients and services.
just add new client name.
url that provide the service
for server services, any implemented type for client
id of the service (service to sid pairing in services table)