Category Archives: web

Basics of HTTP

This is a refresher about the HTTP protocol (citation: RESTful Web Services, 2007, L.Richardson, S. Ruby, O’Rielly Media Inc).

What is HTTP?

HTTP stands for Hypertext Transfer Protocol.

Using the analogy of a document and envelope…

HTTP is a document based protocol:

  1. A client puts a document into an envelope and sends to a server.
  2. The sever puts a response envelope into an envelope and sends to the client.

HTTP has strict standards about the type of envelope but not what goes inside it.

HTTP Request (Client)

The HTTP Method


The Path

The URI to the right of the hostname – this becomes the address on the envelope.

Request Headers

These are key-value pairs that specify infomation about the envelope – there are 46 in all – some of them include: Host, User-Agent, Accept, Keep-Alive…

The Entity Body/Document/Representation

The document inside the envelope.  GET requests never have an entity body, all the information necessary is included in the path and request header.

In POST requests – the entity body could be structured XML to pass over a substantial amount of complex data.  Some web services may take this data and make objects from the XML and feed it into a database, however you do not necesarily have to use XML you can just use plain text, you also don’t have to put the data in a database – you can do what you want with data once you recieve it on the database.

The following shows an example of a GET reqeust to the BBC:

(Request-Line)    GET / HTTP/1.1
User-Agent    Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv: Gecko/2009060215 Firefox/3.0.11
Accept    text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language    en-gb,en;q=0.5
Accept-Encoding    gzip,deflate
Accept-Charset    ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive    300
Proxy-Connection    keep-alive
Cookie    AMOS_PREF=sac%3Dg4; BBC-UID=e4c73e81d4fc55653460b7caa03036f31b6ba10990a0b114b4ffb881cf0ba6450Mozilla%2f5%2e0%20%28Windows%3b%20U%3b%20Windows%20NT%205%2e1%3b%20en%2dGB%3b%20rv%3a1%2e8%2e1%2e12%29%20Gecko%2f20080201%20Firefox%2f2%2e0%2e0%2e12; BBCNewsAudience=Domestic; BBCNewsAudcWght=-99; BBCMediaSelector=m%3Arm&b%3Abb&st%3Ah&ms3%3A4; hp=+acv+ba+neaj+hj+oab*+c1+g1ab+mc2+rad*+da+f1a7b7c7d7+i+kca+la

HTTP Response (Server)

HTTP Response Codes

The code tells the client what happened to their request – did it fail or was success achieved.   There are lots of codes, the most common you will have seen on the web is 404 – which means “Not Found” i.e. the web page was not found on the server.  A success code will usually be 200 i.e. if you got to see the web page you asked for.

Response Header

Pretty much the same as Request Headers e.g. Date, Server, Etag, Content-Type, Last-Modified…

The Entity Body/Document/Representation

In GET requests you actually get an entity body sent to you (or at least you should do!)   The Response Header also makes an important contribution here, like Content-Type – this will tell the client about the media-type to expect (there are many of these) but in the case of a browser rendering an HTML web page it will commonly be text/html.

N.B – media-type can also be referred to as MIME type, content type or data type.

The following is an example of a response from the BBC:

(Status-Line)    HTTP/1.1 200 OK
Via    1.1 BLADEWIN17
Connection    Keep-Alive
Proxy-Connection    Keep-Alive
Content-Length    110652
Date    Wed, 24 Jun 2009 16:00:01 GMT
Age    87
Content-Type    text/html
Server    Apache
Accept-Ranges    bytes
Keep-Alive    timeout=4, max=194


Creating a Restful Web Service Part 1

Objective: To develop a web service that is to be used internally by applications to retrieve and write data to an Oracle database.

I wanted to develop a web service that was designed with the REST framework in mind, SOAP is just too “noisy”, and overly complex.   The web service had to be able connect and interact with an Oracle database, it also had to return any data from the database as XML.  You can view the results directly from a web browser if it’s XML, but it is not really necessary as a web service is mostly a non-human readable resource.

So, I was developing with Java – and had to try an work out what the best tools, APIs would be, bearing in mind the myriad of tools out there on the web.  It took quite a while looking at all the various API’s out there (Spring, Hibernate, iBATIS, EclipseLink, Toplink – the list goes on), but I chose ones that matched the following criteria:
a) if a technology was already in use at work, then that had to be adopted – in order to stop a proliferation of different technologies being used, supported and maintained.

b) easy to use and understand.

c) have decent community support behind them – so if problems arise then at least someone out there may be able to lend a hand.

d) look likely to be well supported in the future without fading into obscurity in the next couple of weeks/months.

Choosing the Right Tools – My Software Stack

  • Java IDE – is Eclipse Europa v3.3.2
  • Apache Tomcat Application Server v5.5.17

A really nice and clean well supported framework.  Some of the tutorials were a bit raw but they have improved of recent and the documentation is getting better all the time.  They are constantly improving the API and stable releases are issued on a resonably regular basis.  They are keen to adopt good standards and it was pleasing to see that WADL is supported in their extended APIs for Restlet.

  • For Object Relational Mapping (ORM) with Oracle I chose Toplink  (version 10g Release 3 and the Workbench software- don’t even think about using raw JDBC API’s – it’s much less work to use Toplink rather than code everything from scratch.
  • For XML to Object ORM, I chose Sun’s JAXB v2.0 implemenation – so, so, so much better than Toplinks crummy efforts (so I am saying Toplink is good for database ORM but not for XML ORM) – I spent so many wasted development hours on this piece of crud – so don’t use it unless you want to a miserable life as a developer.  JAXB is nice, its from Sun so it should conform to some form of standard.  The docs are good and it takes seconds to run the JAXB compiler from a command line along with your XSD schema and generate your Java classes.  Pretty good all round.

In my next post I explain how I used the above to create my REST web service.


Why does anyone use Yahoo anymore other than for webmail and catching some news. Why are Microsoft even bothering trying to buy them out, I don’t get it, there are so many better alternatives to Yahoo!, that are both more of “today”, giving you a more Web 2.0 experience e.g. iGoogle (surprise surprise!). The only thing I can see happening is that Microsoft buy out Yahoo and make it almost the same as how iGoogle operates, because we all know that MS is a bit of magpie of the IT world and nicks other people’s good ideas etc.

Google have basically swatted Yahoo! into relative obscurity in search engine usage, even if Microsoft bought them out and combined their search engines, they would still be lagging behind Google. Don’t get me wrong I’m not really a Google fanboy or anything, but why would you bother using something that’s not all that good when there is better stuff out there. Yahoo is not total rubbish, it’s just a bit passe, and doesn’t really push the envelope or offer anything new.

Google has 59% of US searches, versus about ~20% from Yahoo! (according to That’s a massive share. Yahoo aren’t helping themselves by charging for POP3 email access, who want’s to pay for web mail when it’s been free from the start – MailPlus from Yahoo woooooooh!, how exciting, yes please take my £12 a year for allowing me to access my email on Outlook and er…. better anti spam technology, allegedly – hmmmm my mouths watering. I know it’s only a pound a month, but I just can’t even be arsed paying them and going through all the payment details. So basically I dumped Yahoo not so long ago (and it would have been sooner if I wasn’t that precious about my email address) – I have a gmail account, it’s free too from 3rd party client software, and all round is much much better. It’s survival of the fittest, and Yahoo is looking a bit haggard!