Posts

Program for Convert List to MAP - Java 8

package java8examples; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; public class TestListMap { public static void main(String[] args) {         List<Hosting> list = new ArrayList<>();         list.add(new Hosting(1, "liquidweb.com", 80000));         list.add(new Hosting(2, "linode.com", 90000));         list.add(new Hosting(3, "digitalocean.com", 120000));         list.add(new Hosting(4, "aws.amazon.com", 200000));         list.add(new Hosting(5, "mkyong.com", 1));         // key = id, value - websites         Map<Integer, String> result1 = list.stream().collect(                 Collectors.toMap(Hosting::getId, Hosting::getName));         System.out.println("Result...

ConvertMapToList

package java8examples; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class ConvertMapToList { public static void main(String[] args) {         Map<Integer, String> map = new HashMap<>();         map.put(10, "apple");         map.put(20, "orange");         map.put(30, "banana");         map.put(40, "watermelon");         map.put(50, "dragonfruit");         System.out.println("\n1. Export Map Key to List...");         List<Integer> result = new ArrayList(map.keySet());         result.forEach(System.out::println);         System.out.println("\n2. Export Map Value to List.ZZZZZZZZZZZZZZZZ..");         List<String> result2 = new ArrayList(map.values());   ...

Annotations used in SPRING

Annotations used in SPRING : @Controller @Component @Autowired @RequestMapping : annotation maps portlet requests to appropriate handlers and handler methods. @RenderMapping :  is a method level annotation which is used to map render requests to render methods of handler class. Ex: @RenderMapping(params = "render=viewSuccessPrint") @ResourceMapping : @ResourceMapping(value = "getAutoCompleteListValues") @ActionMapping  : Used to define separete actions in Controller class.            (Save, Submit, FileUpload etc.) @RenderRequest @ResourceRequest While ActionRequest and RenderRequest are distinct classes/objects, they all relate to the same request handling cycle. The main difference is that ActionRequest allows you to change state, RenderRequest does not any more. import javax.portlet.ActionRequest; import javax.portlet.ActionResponse; import javax.portlet.RenderRequest; import javax.portlet.RenderResponse; import...

Sample Spring MVC Controller

package com.mohh.nehr.Hello.Hello.controller; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.UUID; import javax.portlet.ActionRequest; import javax.portlet.ActionResponse; import javax.portlet.RenderRequest; import javax.portlet.RenderResponse; import javax.portlet.ResourceRequest; import javax.portlet.ResourceResponse; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.util.CollectionUtils; import org.springframework.validation.BindingResult; import org.springframework.validation.DataBinder; import org.springframework.web.bind.annotation.RequestMap...

RESTful Web Services

Image
RESTful Web Services Tutorial with Example What is Restful Web Service? REST is used to build Web services that are lightweight, maintainable, and scalable in nature. A service which is built on the REST architecture is called a RESTful service. The underlying protocol for REST is HTTP, which is the basic web protocol. REST stands for REpresentational State Transfer In this tutorial, you will learn- RESTful Key Elements Restful Methods Why Restful Restful Architecture RestFul Principles and Constraints Create your first Restful web service in ASP.NET Running your first Restful web service Testing your first Restful web service RESTful Key Elements Web services have really come a long way since its inception. In 2002, the Web consortium had released the definition of WSDL and SOAP web services. This formed the standard of how web services are implemented. In 2004, the web consortium also released the definition of an additional standard called RESTful. ...