Muitos de vocês devem conhecer o Arun Gupta, Entusiasta de Glassfish com enfase em consolidação web na Sun. Ele foi um dos condutores da especificação da plataforma Java, está comprometidos com diversos projetos de Código Aberto e Software Livre, participou de vários comites de padronização e participou de releases ddo Java EE e SE. É um blogueiro prolífico com várias dicas muito úteis no seu http://blogs.sun.com/arungupta.
Long urls are difficult to remember or print, usually full of redundancy and low semantic. With short and meaningful urls you can avoid thes problems and even achieve profitable goals with SEO
SEO (search engine optimization) technics.
There are services like Tiny URL, Fancy URL, Moo URL and others. Although they solve part of the problems, they bring several others. Another problem is if you have a web site like example.com and use a third-party service for short urls you are losing part of your mind-share with your users and clients.
As an example, if a example.com company wants to promote a open work position would be preferable spread a example.com/jobs instead of a tinyurl.com/examplejobs, or even worst, a tinyurl.com/3i4i592 (meaningless hash).
2. Solution Approach
I created a little program called xort that can be placed on your own server and provide you own short maintening your base url.
I use a pipe abstraction. Each pipe redirects from a key url to an output url.
The idea is that you have xort installed and associated into your domain (preferably on /x). A pipe inside example.com would be like example.com/x/jobs.
All those tools are multi platform, open source and free.
3.1 Glassfish Application Server
Glassfish is an open source application server project led by Sun Microsystems for the Java Enterprise Edition (Java EE) platform. It’s very easy to install and run and have a very nice administration web interface where you can do from simple tasks like deploy a application to more complexes like clustering.
Glassfish Admin Console
To develop the application I’m using NetBeans 6.5 Beta that comes with Glassfish V3 prelude b15b. Netbeans also provides a integration of project, database and web server.
Nevertheless, Glassfish has no dependencies with any IDE and perfectly works by alone. If you need I wrote this post explaining how to install and deploy a application on Glassfish from scratch.
3.2 MySQL Relational Database
MySQL is a relational database management system and probably the most used database on internet (has more than 11 million installations). It’s also very easy to install and administer, through command line or many gui interfaces.
To install MySQL and JDBC driver on Ubuntu just run as root:
You could also create this database by an SQL statement:
To select the database xort:
mysql> use xort;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Now we create a database called pipes with fields pin (pipe in) and pout (pipe out). They represent the input url and the output url of our pipe abstraction.
CREATETABLE pipes (
As we expect a lot of searches queries on this table, we can optionally create a index for it on pin field. This can reduce ours searches from O(n) to O(logn) (because pin’s will be ordered so don’t need to look all pipes, we can use logn algorithms like binary search).
CREATEINDEX pinindex ON pipes (pin);
Another trick to improve our speed is recycling connections through connection pools.
Creating a pool of MySQL connections on Glassfish is very easy. There’re two good tutorials on this subject:
Set if users can add new pipes using the web interface.
JDBC driver to use
Username to login on the database.
Password for the given username.
JDBC path to database.
The default user is admin and password is adminadmin. Log in.
Tip: you be asked for register your version. This register is not mandatory and not doing it will not limit the features of your Glassfish. It’s just a way they use to track the number of users. Aditionaly can have acess to newsletters, tutorials, screencasts, services and support. If you already have a SDN (Sun Developer Network) or Sun Online account you can use it for registration. If you simply doesn’t want to, you can skip this step.
For security reassons, click in the Application Server icon on the left sidebar and so in the Adminstrator Password tab. Chose a new password and click Save.
The views and opinions expressed here are those from me, Silveira Neto. The personal contents in this blog do not necessarily reflect the opinions, ideas, thoughts, points of view, and any other potential attribution of my current, past, or future employers. This blog endorse conversations and free speech and it's open to comments without previous moderation, except for spam. Comments are sole responsibility of their authors, which may choose or not to remain anonymous.