Tuesday 4 August 2009

Give Your Robot a Profile Image

One of the first things I had to overcome was how to give my robot a name and a profile image. It gives a robot an identity so it is easily seen in your contacts list and as it participates in waves.

Although searching the API group gave some hint on what to do, it didn't show all the steps.

The robots I'm developing are using the Java API and I found the following the easiest method to add a profile image and name.

First of all you need to create a ProfileServlet. This extends the ProfileServlet class and is fairly well documented in the API.

Example code:

The final part (which is the part that held me up the most as I couldn't really find it mentioned anywhere) is to update the web.xml file to include the new servlet and to map the servlet.
The following code needs to be added to the web.xml file, replacing testbot.TestbotProfileServlet with your package name/ path to servlet.

After that, you can publish your robot to the appengine and it should now have a profile image and name. If your contact list doesn't update, you may wish to try removing and re-adding the robot as a contact.

1 comment:

  1. i would just like to say thank you for posting this. i have been trying to figure out why my profile wasn't displaying but that last little bit was all i needed. i had seen on other places that i needed to change the web.xml file, however, no other site demonstrated that the servlet and servlet-mapping sections needed to be consecutive for each servlet. thank you again for the info!

    ReplyDelete