1 package com.mockobjects.examples.dynamic; 2 3 import java.io.*; 4 5 import javax.servlet.*; 6 import javax.servlet.http.*; 7 8 11 12 public class SimpleServlet extends HttpServlet { 13 14 private Timer timer; 15 private MailSender mailSender; 16 17 public SimpleServlet(Timer aTimer, MailSender aMailSender) { 18 super(); 19 timer = aTimer; 20 mailSender = aMailSender; 21 } 22 23 public SimpleServlet() { 24 this(null,null); } 26 27 public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 28 29 String body = request.getParameter("body"); 30 String subject = request.getParameter("subject"); 31 String [] recipients = request.getParameterValues("recipients"); 32 String browser = request.getParameter("browser-identifier"); 33 34 37 int age = request.getIntHeader("age"); 38 response.setContentType("text/html"); 39 PrintWriter writer = response.getWriter(); 40 41 writer.print("timer before:" + timer.getTime()); 42 mailSender.sendMail(subject, recipients, body); 43 writer.print("timer after:" + timer.getTime()); 44 45 } 46 47 } 48 | Popular Tags |