title: An exception occurred processing JSP page /AddMemberAction.jsp at line 41
body: <p>I am getting a runtime error . It says that there is null pointer exception in loggermanager.java.</p>
  
  <p>org.apache.jasper.JasperException: An exception occurred processing JSP page /AddMemberAction.jsp at line 41</p>
  
  <pre><code>38:      }
  39:      catch(Exception e)
  40:      { 
  41:        LoggerManager.writeLogWarning(e);
  42:      }
  43:      response.sendRedirect("ViewProjectMembers.jsp");
  44:     %&gt;
  
  
  Stacktrace:
      org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:575)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:477)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  
  
  root cause 
  
  java.lang.NullPointerException
      com.dts.core.util.LoggerManager.writeLogWarning(LoggerManager.java:58)
      org.apache.jsp.AddMemberAction_jsp._jspService(AddMemberAction_jsp.java:135)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.jal
  </code></pre>
  
  <p>Loggermanager.java</p>
  
  <pre><code>package com.dts.core.util;
  
  import java.io.File;
  import java.io.PrintStream;
  import java.util.logging.FileHandler;
  import java.util.logging.Level;
  import java.util.logging.LogManager;
  import java.util.logging.Logger;
  import java.util.logging.SimpleFormatter;
  
  public class LoggerManager {
    public static Logger logger;
  
    public LoggerManager() {}
  
    public Logger getLogger(String file) {
      String dir = file.substring(0, file.lastIndexOf("/"));
      System.out.println("-----dir----" + dir);
      logger = Logger.getLogger("Logger");
      try {
        File f = new File(dir);
        boolean success = f.exists();
  
        if (!success) {
          success = f.mkdir();
        }
        LogManager lm = LogManager.getLogManager();
        FileHandler fh = new FileHandler(file, true);
        logger = Logger.getLogger("LoggerManager");
        logger.setUseParentHandlers(false);
        lm.addLogger(logger);
        logger.setLevel(Level.INFO);
        fh.setFormatter(new SimpleFormatter());
        logger.addHandler(fh);
  
      } catch (Exception e) {
  
        logger.log(Level.INFO, e.toString(), e.fillInStackTrace());
      }
      return logger;
    }
  
    public static void writeLogInfo(Exception e) {
      logger.log(Level.INFO, e.toString(), e.fillInStackTrace());
    }
  
    public static void writeLogSevere(Exception e) {
      logger.log(Level.SEVERE, e.toString(), e.fillInStackTrace());
    }
  
    public static void writeLogWarning(Exception e) {
      logger.log(Level.WARNING, e.toString(), e.fillInStackTrace());
    }
  
    public static void writeLogInfo(String info) {
      logger.log(Level.INFO, info);
    }
  
    public static void writeLogSevere(String severe) {
      logger.log(Level.SEVERE, severe);
    }
  
    public static void writeLogWarning(String warning) {
      logger.log(Level.WARNING, warning);
    }
  }
  </code></pre>
  
  <p>Below is the souce code where LoggerManager.writeLogWarning(3); is present</p>
  
  <pre><code>&lt;%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%&gt;
  &lt;%@ page import="com.dts.core.dao.*,com.dts.core.model.*,com.dts.core.util.*,com.dts.btisqr.model.*,com.dts.btisqr.dao.*" %&gt;
  &lt;%@ page import="java.util.*,com.dts.dae.dao.*,com.dts.dae.model.*"%&gt;
  &lt;%
  String path = request.getContextPath();
  String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
  %&gt;
  
  &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;base href="&lt;%=basePath%&gt;"&gt;
  
      &lt;title&gt;My JSP 'AddMemberAction.jsp' starting page&lt;/title&gt;
  
      &lt;meta http-equiv="pragma" content="no-cache"&gt;
      &lt;meta http-equiv="cache-control" content="no-cache"&gt;
      &lt;meta http-equiv="expires" content="0"&gt;    
      &lt;meta http-equiv="keywords" content="keyword1,keyword2,keyword3"&gt;
      &lt;meta http-equiv="description" content="This is my page"&gt;
      &lt;!--
      &lt;link rel="stylesheet" type="text/css" href="styles.css"&gt;
      --&gt;
  
    &lt;/head&gt;
  
    &lt;body&gt;
     &lt;%
       try
       {
          int projectid = Integer.parseInt(request.getParameter("projectid"));
          String member = request.getParameter("member");   
          Project aProject = new Project();
          aProject.setProjectID(projectid);
          aProject.setAssignedTo(member);
  
          new ProjectsDAO().assignProject(aProject);
       }
       catch(Exception e)
       { 
         LoggerManager.writeLogWarning(e);
       }
       response.sendRedirect("ViewProjectMembers.jsp");
      %&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>