Making POST and DELETE calls to resource URL

As per portlet specification "For use cases that require state changes the serveResource call should be issued via an HTTP method POST or PUT or DELETE." I tried creating a ServeResourceHttpRequestPortlet to check if i can make HTTP PUT or HTTP DELETE call to portlet and i tried it on both WebSphere Portal and Apache Pluto and i got 405: HTTP method DELETE is not not supported by this URL error.

The ServeResourceHttpRequestPortlet is like this

public class ServeResourceHttpRequestPortlet extends GenericPortlet{
protected void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
System.out.println("Entering ServeResourceHttpRequestPortlet.doView()");
response.setContentType("text/html");
getPortletContext().getRequestDispatcher("/index.jsp").include(request, response);
System.out.println("Exiting ServeResourceHttpRequestPortlet.doView()");
}
public void serveResource(ResourceRequest request, ResourceResponse response)
throws PortletException, IOException {
System.out.println("Entering ServeResourceHttpRequestPortlet.serveResource()");
response.setContentType("text/html");
System.out.println("Request method is " + request.getMethod());
response.getWriter().println("HTTP Method used is " + request.getMethod());
System.out.println("Exiting ServeResourceHttpRequestPortlet.serveResource()");
}
}


As you can see the serveResource() method simply returns name of the HTTP method used for making this request.

In the doView(), method i am passing control to index.jsp which is like this

<%@page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1" session="false"%>
<%@taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>

<style type="text/css">
@import src="http://o.aolcdn.com/dojo/1.3.2/dijit/themes/tundra/tundra.css";
@import src=""http://o.aolcdn.com/dojo/1.3.3/dojo/resources/dojo.css";
</style>
<script type="text/javascript" src="http://o.aolcdn.com/dojo/1.3.2/dojo/dojo.xd.js"
djConfig="parseOnLoad:true">
</script>
<portlet:defineObjects />
<script type="text/javascript">
dojo.require("dijit.form.Button");
dojo.require("dojo.parser");
</script>
<table>
<tr>
<td>
<button dojoType="dijit.form.Button" id="get">GET
<script type="dojo/method" event="onClick">
dojo.xhrGet({
url: "<portlet:resourceURL/>",
load: function(data, ioargs){
dojo.byId("resourceResponse").innerHTML = data;
},
error: function(error,ioargs){
alert(error);
}
});
</script>
</button>
</td>
<td>
<button dojoType="dijit.form.Button" id="post">POST
<script type="dojo/method" event="onClick">
dojo.xhrPost({
url: "<portlet:resourceURL/>",
load: function(data, ioargs){
dojo.byId("resourceResponse").innerHTML = data;
},
error: function(error,ioargs){
alert(error);
}
});
</script>
</button>
</td>
<td>
<button dojoType="dijit.form.Button" id="delete">DELETE
<script type="dojo/method" event="onClick">
dojo.xhrDelete({
url: "<portlet:resourceURL/>",
load: function(data, ioargs){
dojo.byId("resourceResponse").innerHTML = data;
},
error: function(error,ioargs){
alert(error);
}
});
</script>
</button>
</td>
<td>
<button dojoType="dijit.form.Button" id="put">PUT
<script type="dojo/method" event="onClick">
dojo.xhrPut({
url: "<portlet:resourceURL/>",
load: function(data, ioargs){
dojo.byId("resourceResponse").innerHTML = data;
},
error: function(error,ioargs){
alert(error);
}
});
</script>
</button>
</td>
</tr>
</table>
<div id="resourceResponse" />


As you can see the index.jsp has 4 buttons which try GET, POST, PUT and DELETE call to the resource URL. As you can see the GET and POST method worked but PUT and DELETE did not