File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes Problem in DELETE operation in REST Webservice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Problem in DELETE operation in REST Webservice" Watch "Problem in DELETE operation in REST Webservice" New topic
Author

Problem in DELETE operation in REST Webservice

Sharmistha Sarkar
Ranch Hand

Joined: Dec 18, 2012
Posts: 44
I am unable to extract HTML FORM values (age, name) in my rest service's java class.

First please look at my web.xml

WEB.XML


in web.xml I have added a filter "HiddenHttpMethodFilter" , It is because some where I saw there is no HTML FORM supports redirect Method as "DELETE" because there are only 2 methods available get and post. So I added this filter to support the Method="DELETE". But I am getting an exception below,



Now, If I don't add the filter I could write Method="GET" and get no exception like this. but I am again unable to extract HTML FORM Values(age , name)

INDEX.HTML


LoginService.java

@Path("/WebService")
public class LoginService {
@DELETE
@Path("/Delete/{age}/{name}")
@Produces("text/plain")

public static void getDelete(@PathParam("age") int age,@PathParam("name") String name) throws Exception {
System.out.println(age+name);

}
}

JARS in MY ECLIPSE BUILD PATH:
1. commons-logging-1.1.1
2. javax.servlet-api-3.0.1 [also I pasted inside <Tomcat>lib....as mentioned in some site]
3. urlrewritefilter-4.0.4
4. cors-filter-1.5.1 [also I pasted inside <Tomcat>lib]

JARS INSIDE WEBCONTENT->WEB-INF->LIB
1.asm-all-3.1.jar
2.asm-attrs-2.2.3.jar
3.asm-commons-4.0.jar
4.asm-util-4.1.jar
5.jersey-client-1.0.3.jar
6.jersey-core-1.0.3.jar
7.jersey-server-1.0.3.jar
8.jsr311-api-1.0.jar

However I just want my HTML Form Values to get into the LoginService.getDelete() and prints the value(age+name). Somewhere I read DELETE method in REST webservice cannot return any value so I gave void in getDelete(). I appreciate if anyone could help me out to resolve . I am stuck on this.
P Kn
Greenhorn

Joined: Mar 09, 2013
Posts: 2
Hi,
i don't think HTML form i the best way to test your service. Check browser's address bar after submitting form. It shows something like:
../REST/WebService/Delete?age=30&name=Test
instead of:
../REST/WebService/Delete/30/Test
which LoginService is expecting. Moreover HTTP method of that request is... GET. Better try using a HTTP/REST client tool, like Simple Http Client (Chrome extension) and it should work.

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41604
    
  55
HTML forms support GET and POST, but none of the other HTTP methods. You need to do a REST call through JavaScript or some other client app.

Also, are you certain that this error "java.lang.ClassNotFoundException: org.springframework.web.filter.HiddenHttpMethodFilter" has no bearing whatsoever on the working of your web app?


Ping & DNS - my free Android networking tools app
 
 
subject: Problem in DELETE operation in REST Webservice