Site Sponsors:
The HTML Sandwich 
This morning I decided to take one of my open-source projects to the next level. -By moving it to the 'web, not only would I add spell checking, but better cross-platform & mobilization options, as well.

The 1-Hour Tech Assessment

At the time of this writing I had been 'giging for a few years on a single set of technologies. Reviewing the web-side implementation options available for a new server-side plunge, as usual we had far too many choices: PHP CRUD, ASP.NET, GWT, Signed Java Applets, Java Server Pages (JSP), Java Server Faces (JSF), etc, etc...

--Such is the dilemma when you know & adore so many technologies!

Full-time Job

In the case of this particular project however, after considering the rate of disruption of everything I knew, I decided to simply use a Servlet.

Why did I select such a basic server-side technology set?

I chose Java because both PHP and .NET seem to ever threaten to leave our code legacies behind. We thereafter decided upon Servlets because - as the foundation of virtually everything on the Java-Web - I likewise tire of the sheer rate of disruption on just about everything built atop of Java Servlet Technology. --Unlike all-things served (Server-ed?) up as Servlet a-la-mode, those good 'ol HTTPRequest & HTTPResponse wrappers have not changed much since their ultimate incarnation.


There are also far too many closed, self-obsoleting standards out there today. -After a few years everyone gets tired of trudging along any cold, hard, forced-march: Those bleak book-biting ascensions along that "upgrade to the latest NOW - that last greatest thing we did was wrong" mountain pass.

Decades after their "me too" d├ębut, has anyone ever heard of SNOBOL or RATFOR?

(-Yea: Ruby-on-Rails is great. Gotcha. (I loved Smalltalk. -Learned Perl, too.))


Now don't get me wrong: If you have a full-time IT staff, then ASP.NET, JSTL, JSF, (etc, etc) are great. -Yet for 90% of the planet however, our site traffic is well under ~250 visitors per second. In as much as that traffic stream is well within the capability of your typical rented-server, if you don't want to spend days catching up on the latest comparative innovations de-jur, then Servlets will do just fine. (Imagine a Qui-Gon Jinn attempt to use a mind trick on Watto...)

Yes.... Just fine.

Indeed, as an army of one, like most low-budget entrepreneurs I simply want to do things once - then get back to doing other things. We'll do it one better if folks like it?

Simple Templates

So the problem arises: Given that one may frequently want to change the style of any given web site, how to do so without tag libraries, code injectors, faces, adaptors, POJOs, entities, and an eager staff of software developers?

At the end of the day, what is the absolute easiest way to skin a site?

... how 'bout an HTML Sandwich?

package com.soft9000.html;


* @author profnagy
public class HtmlTemplate {

static final String sTEMPLATE_DELIM = ".template.";
static final String sTEMPLATE_FILE = ".template.txt";
private File file;
private String delim;

private String prefix = null;
private String suffix = null;

public HtmlTemplate() {

public HtmlTemplate(File file) {
this(file, sTEMPLATE_DELIM);

public HtmlTemplate(File file, String sDelimiter) {
this.file = file;
this.delim = sDelimiter;

public boolean isNull() {
return (file == null || delim == null);

public void getHtml(StringBuilder sb, String content) {
if (sb == null) {
if (prefix == null && split() == false) {


private boolean split() {
if (isNull()) {
return false;
String str = com.soft9000.file.TextReaderF.Read(file);
String[] set = com.soft9000.Text.Split(str, this.delim);
if (set.length != 2) {
return false;
this.prefix = set[0];
this.suffix = set[1];
return true;


Simple, eh?


Inspired by PHP CRUD's "template21", the way that the above class works is easy to understand: By allowing us to specify the name of an external template file, we simply use the "top" and "bottom" of the file as a wrapper around our content. getHtml.

So deign a web page for your entire site, or a subsection thereof. Use graphics, google cookies, style sheets -just the way you want it!

Next, simply put a unique token where you want dynamic content to be inserted then vola! - you will have just what we need to create an "HTML Sandwich Web Site."

Of course, that swap-out could also be for more than a single unique token. -Perhaps a triple, or n-decker, sandwich? Different tokens for different types of content... a 'dagwood? (Yet clearly with a 'tad more bread-foundation, and a allot less baloney (pun intended.))

new BooksRequired == NULL: volatile ReLearningCurve = 0L;


Over time, for internationalization, subscription, and / or other reasons our templates might even be generated dynamically, taken from an SQL CLOB, deducted from competitive web pages, (etc.)

Indeed, no matter if we are using Java, PHP, VB.NET, RUBY, C# or even CGI -w- C/C++ any language can take a byte of that same sandwich.

The dynamic server-ed side don't get any easier than that!

Sharing is caring,


[ view entry ] ( 533 views )   |  permalink  |  related link
Setting-up Hadoop 2 on Linux in 3 Easy Steps 
When the time came to pick a 'distro for use by our Hadoop students, because the Hortonworks VM was using CentOS (love it), just to round the student experience out a bit I decided to use Ubuntu.

Hadoop 2.2.0 is still about Java. If you are thinking production, be sure to use Oracle Java 1.6.

STEP 01: Source Install (OPTIONAL)

Obviously tracking to an LTS version, when you want to set-up the source code for Hadoop for spelunking on Linux (first-timers will want to avoid this step!), then you will want to do the following:
sudo bash
apt-get install maven
apt-get install git
apt-get update
apt-get upgrade
mkdir /hadoop9000
cd /hadoop9000
git clone git://
cd hadoop-common
mvn install -DskipTests
mvn eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true
chown guest /hadoop9000 (or whoever)

The above will create the latest Hadoop on your machine. -To keep your production work moving along on the Hadoop 2 LCD, then also consider using the official binary install.

DEVELOPER NOTE: If you are looking to use your install for software development, note that the above step is not optional. Why? Because native mode libraries (as well as the rest of the lot) need to be generated for your R&D Platform. Depending upon the version of Linux you have, you may also need to install projects like ptotocol buffers (etc.) to compile Hadoop's C/C++ JNI underpinnings. Once created, just chum the lot of the 50-or-so libraries into /hadoop9000/lib. Why? Because you will want to use those JARs in your IDE (eclipse, netbeans, etc.) from a single standard location.

STEP 02: Official Binary Install (REQUIRED)

If rebuilding from the source is not what you want to do, then you can simply download & unzip the hadoop tar under /hadoop9000.

Note that if using gzip compressing is on the radar, then we will need to be sure to provide the proper 32 / 64 rendition of Hadoop's native libraries, as well. (Step 01 can build those native libraries for us, too. Use: mvn compile -Pnative )

STEP 03: Hadoop Environment Variables (REQUIRED)

Next, those Hadoop environment variables need to be wired-into your .bashrc: (The embolden ones are required - the rest are optional)
export JAVA_HOME="/usr/lib/jvm/java-6-oracle"
export HADOOP_HOME="/hadoop9000"

export HIVE_INSTALL="$HADOOP_HOME/hive/hive-0.12.0-bin"
# Can also place into
#export HADOOP_OPTS="$HADOOP_OPTS -Djava.library.path=$HADOOP_HOME/lib/"
Yes, Oracle Java (/usr/lib/jvm/java-6-oracle) is officially endorsed as the the best real-world way to go on Hadoop.

Chasing the Moths

When debugging, do not forget to edit the

This should get you started. If you need to learn more, then consider signing-up for our next week of virtual training on Hadoop.



[ view entry ] ( 1132 views )   |  permalink  |  related link
Taking Stock from 
From the corporation to the cloud, today more and more people are talking about "Web Services." Indeed, whilst most folks understandably feel that GET, POST, and HTML have certainly been serving us all rather well, the hottest trend in recent memory is to provide XML-based Web Services.

A few years back SOAP based Services were so 'hot' that IBM, Microsoft, and XMethods all provided phone-book type repositories for 3rd part Web Services. Today however, the last standing place to go for free-and-open independent Web Services remains the same as before the others came and went:

For the sake of efficiency, the current underpinnings for Web Service delivery is decidedly moving away from fat-and-chatty XML-centric content-exchange. Yet while conventions such as REST and JSON offer very real performance alternatives to SOAP, when it come to exchanging service definitions, XML remains king.

Since the new crop of XML-defined Web Services are at the heart of everything from SOA to ESB, whenever there is an interest in a class I like to present a short meandering past the WSDL workings of XMethods. While I have hosted a few services there myself, since Microsoft's second MSXML melt-down, in class my students and I like to use a free Stock Quote Service.

package com.soft9000;

import java.rmi.RemoteException;

import net.restfulwebservices.www.DataContracts._2008._01.StockQuote;
import net.restfulwebservices.www.ServiceContracts._2008._01.IStockQuoteServiceProxy;

public class Main {

public static void main(String[] args) {
IStockQuoteServiceProxy pox = new IStockQuoteServiceProxy();
try {
StockQuote quote = pox.getLastQuote("IBM");
} catch (RemoteException e) {
// TODO Auto-generated catch block


Of course, the best part of defining services in XML is that once we paste the endpoint (or - depending upon the IDE - the XML document itself) that code can be generated.

The rest is academic - but the above is an example of how to use one of the many XMethods web services under Eclipse.



[ view entry ] ( 2116 views )   |  permalink  |  related link

<<First <Back | 1 | 2 | 3 | 4 |