Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

sevlet addTask

Sharishah97 Nov 14th, 2018 93 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1.  
  2. package com.awesometodo.controller;
  3.  
  4. import java.io.IOException;
  5. import java.util.List;
  6.  
  7. import javax.naming.NamingException;
  8. import javax.servlet.ServletException;
  9. import javax.servlet.annotation.WebServlet;
  10. import javax.servlet.http.HttpServlet;
  11. import javax.servlet.http.HttpServletRequest;
  12. import javax.servlet.http.HttpServletResponse;
  13.  
  14.  
  15. import com.awesometodo.model.TaskBean;
  16. import com.awesometodo.model.manager.EJBFactoryT;
  17. import com.awesometodo.model.manager.TaskBeanManagerLocal;
  18.  
  19. /**
  20.  * Servlet implementation class AddTask
  21.  */
  22. @WebServlet("/AddTask")
  23. public class AddTask extends HttpServlet {
  24.     private static final long serialVersionUID = 1L;
  25.        
  26.     /**
  27.      * @see HttpServlet#HttpServlet()
  28.      */
  29.     public AddTask() {
  30.         super();
  31.         // TODO Auto-generated constructor stub
  32.     }
  33.  
  34.     /**
  35.      * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
  36.      */
  37.     protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  38.         // TODO Auto-generated method stub
  39.         //doGet(request, response);
  40.        
  41.         String taskId = request.getParameter("null");
  42.         String userId = request.getParameter("null");
  43.         String task = request.getParameter("task");
  44.         String due = request.getParameter("due");
  45.         String priority = request.getParameter("priority");
  46.        
  47.         TaskBean tb = new TaskBean(taskId,userId,task,due,priority);
  48.         System.out.println(tb.toString());
  49.        
  50.         try
  51.         {
  52.             //get EJB and call function to register the user
  53.             EJBFactoryT ejbm = new EJBFactoryT();
  54.             TaskBeanManagerLocal ubm = ejbm.getTaskBeanManagerLocal();
  55.             ubm.addTask(tb);
  56.            
  57.             //check value in our stateless bean, debugging purpose only
  58.             List<TaskBean> tasks = ubm.getTaskList();
  59.             System.out.println("No of task added: " + tasks.size());
  60.             System.out.println("Task list:");
  61.             System.out.println(tasks.toString());
  62.         } catch (NamingException e) {
  63.             e.printStackTrace();
  64.         }
  65.        
  66.         //HttpSession session = request.getSession();
  67.         request.setAttribute("taskbean", tb);
  68.         request.getRequestDispatcher("addTaskSuccess.jsp").forward(request, response);
  69.     }
  70.  
  71. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top