addheader

Friday, 1 February 2013

restful webservice formparam example

restful webservice formparam example:


     JAVA-SERVLETS     JAVA-JDBC     JAVA-JSP       HIBERNATE-SHCEMABASED 

    SPRING-AOP-ANNOTATIONS      SPRING -DAO     SPRIN-MVC     SPRING-SECUTITY

     SPRING-DATA-JPA     REST-WEB-SERVICE     STRUTS2HIBERNATE    GWT.... 


---------------------------------------




PathParamMulValService .java
--------------------------------


package madhav;
import javax.ws.rs.FormParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
@Path("/formparam")
public class FormParamService {
 @POST
 @Path("/add")
 public String handleForm(@FormParam("id") String id,@FormParam("name") String name){

  //business logic

  return "id=" + id + "," + "name= " + name;
 }

}



web.xml
--------



<?
xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name></display-name>
<servlet>
<display-name>JAX-RS REST Servlet</display-name>
<servlet-name>JAX-RS REST Servlet</servlet-name>
<servlet-class>
com.sun.jersey.spi.container.servlet.ServletContainer
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>JAX-RS REST Servlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>


studentform.html
-------------------------

<html>
<head>
<title>studentform.html</title>
</head>
<body bgcolor="wheat">
<form action="services/formparam/add" method="post">
<p>
id : <input type="text" name="id" />
</p>
<p>
name : <input type="text" name="name" />
</p>
<input type="submit" value="Add student" />
</form>
</body>




 
output -client as html::
----------------------






Related topics:

                       Restful webservice json,spring dao

2.     Restfulwebservice java, jquery, json,ajax example


3.     Structr2 hibernate 3 integration example program


4.     springmvc spring provided hibernate example


5.     struct 2 spring dao


6.     struts 2hibernate integration example 

   7. Jquery autocomplete from database restful webservice json,ajax


    8.     jax-rs say hai example program

     9.     jax-rs @pathparam example

     10.     jax rs @pathparam multiple value example

     11.     jax rs @Formparam  example


     JAVA-SERVLETS     JAVA-JDBC     JAVA-JSP       HIBERNATE-SHCEMABASED 

    SPRING-AOP-ANNOTATIONS      SPRING -DAO     SPRIN-MVC     SPRING-SECUTITY

     SPRING-DATA-JPA     REST-WEB-SERVICE     STRUTS2HIBERNATE    GWT.... 



No comments:

Post a Comment