package com.cv.jsp.el.attribute;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
/**
* Servlet implementation class ServletAttributeImpl
*
* @author Chandra Vardhan
*/
public class ServletAttributeImpl extends HttpServlet {
private static final Logger LOGGER = Logger
.getLogger(ServletAttributeImpl.class);
protected void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
LOGGER.info("LOGGER : ServletAttributeImpl doGet(HttpServletRequest,HttpServletResponse)");
// PrintWriter pw = res.getWriter();
res.setContentType("text/html");
String name = req.getParameter("name");
String id = req.getParameter("empId");
Person person = new Person();
person.setName(name);
person.setEmpId(Integer.parseInt(id));
Dog dog = new Dog();
dog.setName("Jokey");
person.setDog(dog);
req.setAttribute("person", person);
// Arraylist
List<String> al = new ArrayList<String>();
al.add("Chandra");
al.add("Shravya");
al.add("Vardhan");
req.setAttribute("list", al);
Map<String, String> map = new HashMap<String, String>();
map.put("key1", "Baapu");
map.put("key2", "Akka");
map.put("key3", "Amma");
req.setAttribute("map", map);
Map<Person, String> map2 = new HashMap<Person, String>();
map2.put(person, "person1");
req.setAttribute("personMap", map2);
String[] companies = { "Amazon", "Salesforce", "Google", "Microsoft" };
req.setAttribute("companies", companies);
RequestDispatcher rd = req.getRequestDispatcher("result.jsp");
rd.forward(req, res);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
LOGGER.info("LOGGER : ServletAttributeImpl doGet(HttpServletRequest ,HttpServletResponse )");
doPost(request, response);
}
} |
As we know there are many companies which are converting into Big data service providers. with the right direction we can definitely predict the future.
ReplyDelete