Hi,
I am newbie to rest. I am using the following code example to understand the RESTlet.
http://www.restlet.org/documentation/1.1/firstResource
I am using RESTClient addon to firefox for testing.
When i do GET on http://localhost/rest, i get a response "ok".
But when i do GET on http://localhost/items, I get an error "404 Not found"
Here's the sample code:
public synchronized Restlet createRoot() {
Router router = new Router(getContext());
router.attach("/items", ItemsResource.class);
router.attach("/items/{itemName}", ItemResource.class);
Restlet restlet = new Restlet() {
@Override
public void handle(Request request, Response response) {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("ok");
response.setEntity(new StringRepresentation(stringBuilder
.toString(), MediaType.TEXT_HTML));
}
};
router.attach("/rest", restlet);
return router;
}
ItemResource is same as provided in the link. and I use tomcat to run the servlet.
Why am I getting the "Not found" error? Am i missing something here?
Thanks & Regards,
Anandan