// Path: mvc/Servlet30HelloWorld/src/main/java/com/sample/dynamic/CalculatorServlet.java
// public class CalculatorServlet extends HttpServlet {
//     private static final long serialVersionUID = -2237206745594453412L;
//     private static final Logger log = Logger.getLogger(CalculatorServlet.class);
// 
//     @Override
//     public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//         String[] inputVals = request.getParameterValues("inputVals");
//         double result = 0.0d;
//         int index = 0;
//         for (index = 0; index < inputVals.length; index++) {
//             try {
//                 result += Double.valueOf(inputVals[index]);
//             } catch (NumberFormatException nfe) {
//                 log.warn("Could not parse value:" + inputVals[index]);
//             }
//         }
//         request.setAttribute("result", result);
//         request.getRequestDispatcher("/dynamic_pages/calc_result.jsp").forward(request, response);
//     }
// }


import com.sample.dynamic.CalculatorServlet;
import org.apache.log4j.Logger;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.ServletRegistration;
import javax.servlet.annotation.WebListener;
package com.sample.listeners;



/**
 * Application Lifecycle Listener implementation class SessionListener
 */
@WebListener
public class SessionListener implements ServletContextListener {

    private static final Logger log = Logger.getLogger(SessionListener.class);

    /**
     * @see ServletContextListener#contextDestroyed(ServletContextEvent)
     */
    public void contextDestroyed(ServletContextEvent sce) {
        log.info("Destroying context .... ");
    }

    /**
     * @see ServletContextListener#contextInitialized(ServletContextEvent)
     */
    public void contextInitialized(ServletContextEvent sce) {
        log.info("Initiating context ... ");
        ServletContext sc = sce.getServletContext();
// Path: mvc/Servlet30HelloWorld/src/main/java/com/sample/dynamic/CalculatorServlet.java
// public class CalculatorServlet extends HttpServlet {
//     private static final long serialVersionUID = -2237206745594453412L;
//     private static final Logger log = Logger.getLogger(CalculatorServlet.class);
// 
//     @Override
//     public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//         String[] inputVals = request.getParameterValues("inputVals");
//         double result = 0.0d;
//         int index = 0;
//         for (index = 0; index < inputVals.length; index++) {
//             try {
//                 result += Double.valueOf(inputVals[index]);
//             } catch (NumberFormatException nfe) {
//                 log.warn("Could not parse value:" + inputVals[index]);
//             }
//         }
//         request.setAttribute("result", result);
//         request.getRequestDispatcher("/dynamic_pages/calc_result.jsp").forward(request, response);
//     }
// }


// Path: mvc/Servlet30HelloWorld/src/main/java/com/sample/listeners/SessionListener.java
import com.sample.dynamic.CalculatorServlet;
import org.apache.log4j.Logger;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.ServletRegistration;
import javax.servlet.annotation.WebListener;

package com.sample.listeners;



/**
 * Application Lifecycle Listener implementation class SessionListener
 */
@WebListener
public class SessionListener implements ServletContextListener {

    private static final Logger log = Logger.getLogger(SessionListener.class);

    /**
     * @see ServletContextListener#contextDestroyed(ServletContextEvent)
     */
    public void contextDestroyed(ServletContextEvent sce) {
        log.info("Destroying context .... ");
    }

    /**
     * @see ServletContextListener#contextInitialized(ServletContextEvent)
     */
    public void contextInitialized(ServletContextEvent sce) {
        log.info("Initiating context ... ");
        ServletContext sc = sce.getServletContext();
        ServletRegistration registrar = sc.addServlet("calc", CalculatorServlet.class);