title: The type getServletContext() is undefined for the type HttpServletRequest in a maven project for Eclipse
body: <p>I was following an example online but when I use the certain function request.getServletContext().getServletRegistrations(). It does not recognize this function</p>
  
  <pre><code> //   Check the target of the request is a servlet?
   private boolean needJDBC(HttpServletRequest request) {
     System.out.println("JDBC Filter");
  
     String servletPath = request.getServletPath();
     // =&gt; /abc/mnp
     String pathInfo = request.getPathInfo();
  
     String urlPattern = servletPath;
  
     if (pathInfo != null) {
         // =&gt; /spath/*
         urlPattern = servletPath + "/*";
     }
  
     // Key: servletName.
     // Value: ServletRegistration
  
     Map&lt;String, ? extends ServletRegistration&gt; servletRegistrations = request.getServletContext()
             .getServletRegistrations();
  
     // Collection of all servlet in your webapp.
     Collection&lt;? extends ServletRegistration&gt; values = servletRegistrations.values();
     for (ServletRegistration sr : values) {
         Collection&lt;String&gt; mappings = sr.getMappings();
         if (mappings.contains(urlPattern)) {
             return true;
         }
     }
     return false;
  }
  </code></pre>
  
  <p>When I use this same function in a regular dynamic web project it works fine with no errors, but using maven these same methods are undefined. I tried to change the 
      request.getServletContext().getServletRegistrations(); </p>
  
  <p>to 
      request.getSession().getServletContext().getServletRegistrations();</p>
  
  <p>I recognized the getSession.getServletContext(), but it then doesn't recognize the getServletRegistrations(). I figured it might've been a dependencies problem so I added several dependencies to my pom.xml</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;com.ers&lt;/groupId&gt;
  &lt;artifactId&gt;ERSProject&lt;/artifactId&gt;
  &lt;packaging&gt;war&lt;/packaging&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;name&gt;ERSProject Maven Webapp&lt;/name&gt;
  &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  
  
  &lt;repositories&gt;
      &lt;!-- Repository for ORACLE ojdbc6. --&gt;
      &lt;repository&gt;
          &lt;id&gt;codelds&lt;/id&gt;
          &lt;url&gt;https://code.lds.org/nexus/content/groups/main-repo&lt;/url&gt;
      &lt;/repository&gt;
  &lt;/repositories&gt;
  
  
  
  &lt;dependencies&gt;
  
      &lt;!-- Oracle database driver --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.oracle&lt;/groupId&gt;
          &lt;artifactId&gt;ojdbc6&lt;/artifactId&gt;
          &lt;version&gt;11.2.0.3&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;junit&lt;/groupId&gt;
          &lt;artifactId&gt;junit&lt;/artifactId&gt;
          &lt;version&gt;3.8.1&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;!-- https://mvnrepository.com/artifact/org.glassfish.web/javax.servlet.jsp.jstl --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.web&lt;/groupId&gt;
          &lt;artifactId&gt;javax.servlet.jsp.jstl&lt;/artifactId&gt;
          &lt;version&gt;1.2.5-b03&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- https://mvnrepository.com/artifact/javax.servlet.jsp.jstl/javax.servlet.jsp.jstl-api --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet.jsp.jstl&lt;/groupId&gt;
          &lt;artifactId&gt;javax.servlet.jsp.jstl-api&lt;/artifactId&gt;
          &lt;version&gt;1.2.1&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;javax.servlet-api&lt;/artifactId&gt;
          &lt;version&gt;3.0.1&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
  &lt;/dependencies&gt;
  &lt;build&gt;
      &lt;finalName&gt;ERSProject&lt;/finalName&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p></p>
  
  <p>Any help would be greatly appreciated. Thank You.</p>