Posts

Showing posts with the label html

RESTful WS using Jersey Part 3 – Java Client

This post is with reference of Restful WS using Jersey Part 2 – Parameterized approach to provide a java client for accessing Restful services The Complete code for Java Client /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package demo.client; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; /** * * @author Yogesh */ public class JavaClient {     public static void main(String[] args) {         String restUrlStr = " http://localhost:17286/HelloWorldRestWSPrj/resources/hello/Yogesh?query=age";         URLConnection conn = null;         try {             URL restUrl = new URL(restUrlStr);   ...

RESTful WS using Jersey Part 2 – Parameterized approach

Image
This post is in sequel  RESTful WS using Jersey Part 1 - Hello World . It shows how to utilize parameterized urls as well as query string. Please refer Part 1 to know developing restful services from scratch. This post utilizes same example. Parameters can be passed as part of path as well as url query string. Jersey provides two annotations @PathParam   and @QueryParam for extracting parameters from path and query respectively. We have modified getText method to accept both kind of parameters as below 1. Complete resource class will be package demo.resorces; import javax.ws.rs.core.Context; import javax.ws.rs.core.UriInfo; import javax.ws.rs.PathParam; import javax.ws.rs.Consumes; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.GET; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; /** * REST Web Service * * @author Yogesh */ @Path("hello/{UserName}") p...