package com.cv.jsp.actions;
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 JspServlet
*
* @author Chandra Vardhan
*
*/
public class JspServlet extends HttpServlet {
private static final Logger LOGGER = Logger.getLogger(JspServlet.class);
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
LOGGER.info("LOGGER : JspServlet doGet(HttpServletRequest,HttpServletResponse)");
doPost(request, response);
}
protected void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
LOGGER.info("LOGGER : JspServlet doPost(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.empID = Integer.parseInt(id);
Dog dog = new Dog();
dog.setName("jimmy");
person.setDog(dog);
req.setAttribute("name", person);
req.setAttribute("person", person);
req.setAttribute("xxx", person);
ManyParam mp = new ManyParam();
mp.setName(name);
req.setAttribute("manyParam", mp);
String[] list1 = { "chandra", "kodam", "vardhan", "netha" };
String[] list2 = { "shrvya", "sreepati", "nice", "nara" };
List list = new ArrayList();
list.add(list1);
list.add(list2);
req.setAttribute("list", list);
Map<String,String> map = new HashMap<String,String>();
map.put("name", "chote");
req.setAttribute("map", map);
RequestDispatcher rd = req.getRequestDispatcher("Choose_when.jsp");
rd.forward(req, res);
}
} |
No comments:
Post a Comment