Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Problem in DELETE operation in REST Webservice

 
Ranch Hand
Posts: 50
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Rancher
Posts: 43026
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
All of life is a contant education - Eleanor Roosevelt. Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic