HtmlUnit – How to do a POST

June 24, 2009


I’ve just started using HtmlUnit (I also use Selenium but find it too slow for 90% of my testing).

HtmlUnit is generally easy to work with. Generally, it doesn’t need documentation as the Javadoc is useful and the methods are obvious. However, this is not the case for POST… so, here is how you do a POST 🙂

How to do a POST in HtmlUnit

There really isn’t much to it – you just need to know what code to use:

final WebClient webClient = new WebClient();

// Instead of requesting the page directly we create a WebRequestSettings object
WebRequestSettings requestSettings = new WebRequestSettings(
  new URL("URL GOES HERE"), HttpMethod.POST);

// Then we set the request parameters
requestSettings.setRequestParameters(new ArrayList());
requestSettings.getRequestParameters().add(new NameValuePair("name of value to post", "value"));

// Finally, we can get the page
HtmlPage page = webClient.getPage(requestSettings);

Quite a lot of work for a simple… I imagine it won’t be hard to wrap this up into a neat POST method.


I feel good! (Follow-up on Lessons Learned!)

June 17, 2009

I feel good. I am more productive and happier in my life.


I’m working less.


The conclusion of my previous blog post was that I should try to work less. So, I’ve been forcing myself to ~7-8 hours every day.

Working less but getting more done?

Yes. I am motivated because I have had time to relax and reflect.


You bet.

How I Have Failed – Lessons From My First Four Months of a Startup

June 10, 2009

Over the past few days I have taken some time to reflect on the previous few months and think about how I have failed in various ways and also how I have done well 🙂

As some of you will know I left my job in February to become the technical director in an early stage startup (actually I do everything technical and also a bit of the business work – that’s the joy of a small team!). Since then we’ve done a lot of great work, but I have also done my fair share of things that should now be thought of as learning opportunities. I’m going to take some time to go over a few of them as I think I’m not alone in making these mistakes!

Disclaimer: This is a bit of a brain dump – mostly self-indulgence for me in actually straightening out my thoughts!

Not Pausing For Reflection

It’s taken me four months to sit back and go “Are we doing this right? How am I behaving? What should I be changing?”. Sure, I’ve paid lip service to doing this but I’ve not properly sat down and given it serious thought. This is far too long to go without doing this – I’m confident I would be guilty of committing fewer of my sins below if I had done this.

So, I’m now going to sit down once a month and have a good think 🙂

Not Releasing Quick Enough

The product that we are developing is now in a public beta and we’re about to go for a big launch. We could have launched a few months ago with fewer bells and whistles. This would have given us far more time to listen to what people are saying instead of guessing and making a few mistakes. On the flip side, we could have wasted our opportunity to build momentum as people saw it and thought “this is rubbish”. However, that doesn’t seem to have been a problem for Facebook, MySpace, Twitter, etc… I think that most people these days are quite happy to accept an evolving service – so long as it isn’t breaking. I also think this is a good way to build and sustain hype – people talk about new features / design tweaks.

Not Treating Close Friends with Sufficient Respect

This is a haenous crime and I apologise to everyone who has been on the receiving end of this.

As my startup is basically my life I’ve told my closest friends quite a lot about it. This means that when they later talk to me I forget that they aren’t as absorbed as I am and don’t know my reasoning behind things when I shoot down a suggestion from them. A typical conversation might go:

Them: I think you should do X

Me: That won’t work. The demand isn’t there for it.

And I’ll try to end the conversation there. Bad idea. Often the idea is a great idea there is just some nuance of the business that makes it inapplicable in our case. I should thank them for their idea and explain to them my reasoning for any bold statement about the idea.

Optimising Early

Guilty. I did some scaling testing and scalability was OK… but I wanted more bang for our buck. This is the sort of thing that (provided you know how you’re going to do it) can be done later when you’ve actually proven the business is meeting a demand.

Working Too Much

It’s very easy to get absorbed into your very own startup. So easy that I have ended up spending a lot of time either working on it or doing things very closely related. The result: friendships suffer, my concentration suffers and my ability to make good decisions becomes less… good. I’m now setting a rule of no work after 8pm and preferably no work after 6pm 🙂

Not Networking Enough

I’ve blamed this on moving away from London and the time it takes to commute there and back. In truth, I’m lazy and I’ve been working too much. If I’m sensible about how I work then I can easily get myself to some good events, have a good time and meet some great people!

I’m going to start making myself get to at least one event a month… am open to fun suggestions in London!

Allowed Things to Drag

Certain business decisions we’ve made have been allowed to drag on for far too long. We’ve tried to be clever about it and get the best timing, make the best decision etc etc… but I think this has been us covering up for indecision. If we don’t know how to make a decision we should be thinking about what we need to know to make that decision.

I’m going to start forcing decisions – or forcing gathering the knowledge we need – or developing an action plan for getting somewhere with the decision

Not Blogging Enough

This is a similar point to the reflection point. The act of blogging is a great way for me to get my thoughts out and clear my mind. I can then focus far better afterwards!

I’m going to try to blog once a week

My Focus For Personal Development

I know it’s hard to improve several things at once… so, I’m going to focus on not working too hard and hope the rest falls into place. In a months time we’ll see where I have got!

One last thing… The Good?

To summarise the good: we’ve developed a really neat looking product that we’re proud of it. I’m proud of it 🙂 I’ll share it with you all soon! (I realise I’m continuing to violate “not releasing quick enough” but there’s only a few days left till we launch so might as well hold on!)