title: How to Create REST Client, the response should be come in JSP page?
body: <p>I developed server side web services developed with rest. My Code working fine while checking with POSTMAN application. But i want to get the response for all the CRUD operation in JSP page. The every response should be display in JSP page and The Data consumes should be JSP page. Could you please provide way for how to develop REST Client. I am new to Rest Client.</p>
  
  <p>Product.java</p>
  
  <pre><code>public class Product {
  
  private long pid;
  private String pname;
  private String category;
  private float price;
  private long stock;
  private String remarks;
  
  public Product()
  {
  
  }
  
  public Product(long pid,String pname,String category,float price,long stock,String remarks){
      this.pid=pid;
      this.pname=pname;
      this.category=category;
      this.price=price;
      this.stock=stock;
      this.remarks=remarks;
  }
  public long getPid() {
      return pid;
  }
  public void setPid(long pid) {
      this.pid = pid;
  }
  public String getPname() {
      return pname;
  }
  public void setPname(String pname) {
      this.pname = pname;
  }
  public String getCategory() {
      return category;
  }
  public void setCategory(String category) {
      this.category = category;
  }
  public float getPrice() {
      return price;
  }
  public void setPrice(float price) {
      this.price = price;
  }
  public long getStock() {
      return stock;
  }
  public void setStock(long stock) {
      this.stock = stock;
  }
  public String getRemarks() {
      return remarks;
  }
  public void setRemarks(String remarks) {
      this.remarks = remarks;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>DatabaseClass.java</p>
  
  <pre><code>public class DatabaseClass {
  
  private static Map&lt;Long, Product&gt; products=new HashMap&lt;&gt;();
  
  public static Map&lt;Long, Product&gt; getProduct()
  {
      return products;
  }   
  </code></pre>
  
  <p>}</p>
  
  <p>ProductDaoImpl.java</p>
  
  <pre><code>public class ProductDaoImpl implements ProductDao {
  
  private Map&lt;Long, Product&gt; products=DatabaseClass.getProduct();
  
  public ProductDaoImpl()
  {
      products.put(1L, new Product(1L,"TV","Entertinement",10000F,250L,"This is best TV!"));
      products.put(2L, new Product(2L,"Computer","Technology",20000F,350L,"My Computer name Hp and SONY ViVo!"));
      products.put(3L, new Product(3L,"DeskTopComputer","Technology",15000F,150L,"My Desktop Computer name Accer and SONY ViVo!"));
  }
  
  //Get All products
  public List&lt;Product&gt; getAllProducts() {
  
      return new ArrayList&lt;Product&gt;(products.values());
  }
  
  //Get product by product id
  public Product getProduct(long pid) {
  
      return products.get(pid);
  }
  
  //To Add the products 
  public Product addProduct(Product product) {
      product.setPid(products.size()+1);
      products.put(product.getPid(), product);
      return product;
  }
  
  //Update the product
  public Product updateProduct(Product product) {
      if(product.getPid()&lt;=0)
      {
          return null;
      }
      products.put(product.getPid(), product);
      return product;
  }
  
  // Delete the product
  public Product deleteProduct(long pid) {
  
      return products.remove(pid);
  
  }
  
  
  
  //Get the product by category
  public List&lt;Product&gt; getProductByCategory(String category) {
  
      List&lt;Product&gt; list = new ArrayList&lt;Product&gt;();
  
      if (products.size()&lt;=0) {
          return null;
      }
  
      else{
  
          for(Product p: this.products.values()){
  
              if(p.getCategory().equals(category))
                  list.add(p);    
          }
          return list;    
      }
  
  }
  
  //Get the product by price
  public List&lt;Product&gt; getProductsBasedOnPrice(float startPrice, float endPrice) {
  
      List&lt;Product&gt; list = new ArrayList&lt;Product&gt;();
  
      if (products.size()&lt;=0) {
          return null;
      }
  
      else{
  
          for(Product p: this.products.values()){
  
              if(startPrice&lt;=p.getPrice() &amp;&amp; endPrice&gt;=p.getPrice())
              {
                  list.add(p);    
              }
          }
          return list;    
      }
  
  }}
  </code></pre>
  
  <p>ProductServiceImpl.java</p>
  
  <pre><code>@Path("/products")
  </code></pre>
  
  <p>public class ProductServiceImpl implements ProductService {</p>
  
  <pre><code>ProductDaoImpl productService=new ProductDaoImpl();
  
  @GET
  @Produces(MediaType.APPLICATION_XML)
  public List&lt;Product&gt; getProducts() {
  
      return productService.getAllProducts();
  }
  
  @GET
  @Path("/{pid}")
  @Produces(MediaType.APPLICATION_XML)
  public Product getProduct(@PathParam("pid") long pid)
  {
      return productService.getProduct(pid);
  }
  
  @POST
  @Produces(MediaType.APPLICATION_XML) 
  @Consumes(MediaType.APPLICATION_XML)
  public Product addMessage(Product product)
  {
      return productService.addProduct(product);
  }
  
  @PUT
  @Path("/{pid}")
  @Produces(MediaType.APPLICATION_XML) 
  @Consumes(MediaType.APPLICATION_XML)
  public Product updateProduct(@PathParam("pid") long pid,Product product)
  {
      product.setPid(pid);
      return productService.updateProduct(product);
  }
  
  @DELETE
  @Path("/{pid}")
  @Produces(MediaType.APPLICATION_XML) 
  public void deleteMessage(@PathParam("pid") long pid)
  {
      productService.deleteProduct(pid);
  }
  
  @GET
  @Path("category/{category}")
  @Produces(MediaType.APPLICATION_JSON)
  public List&lt;Product&gt; getProductsBasedOnCategory(@PathParam("category") String category) {
  
      return productService.getProductByCategory(category);
  }
  
  
  @GET
  @Path("basedOnPrice")
  @Produces(MediaType.APPLICATION_JSON)
  public List&lt;Product&gt; getProductsBasedOnPrice(@QueryParam("startPrice") float startPrice, @QueryParam("endPrice") float endPrice) {
              if(startPrice&gt;0 &amp;&amp; endPrice&gt;0)
              {
              return productService.getProductsBasedOnPrice(startPrice, endPrice);    
              }
      return productService.getAllProducts();
  }
  </code></pre>
  
  <p>}</p>