title: JSP Error- illegal to have multiple occurrences of 'contentType' with different values
body: <p>I am working on the Netbeans Affable tutorial on this <a href="https://netbeans.org/kb/docs/javaee/ecommerce/manage-sessions.html#time-out" rel="nofollow">page</a> using the Netbeans 7 IDE , Glassfish 3+ server , the servlet class and session beans. The servlet class is expected to invoke the index.jsp class.</p>
  
  <p>But anytime I run the project in Netbeans I get an error. </p>
  
  <p>this is the index.jsp page.</p>
  
  <pre><code>&lt;%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%&gt;
  &lt;%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%&gt;
  
  &lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
          &lt;link rel="stylesheet" type="text/css" href="css/affablebean.css"&gt;
      &lt;title&gt;The Affable Bean&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
  
          &lt;div id="indexLeftColumn"&gt;
                  &lt;div id="welcomeText"&gt;
                      &lt;p style="font-size: larger"&gt;Welcome to the online home of the Affable Bean Green Grocer.&lt;/p&gt;
  
                      &lt;p&gt;Enjoy browsing and learning more about our unique home delivery
                          service bringing you fresh organic produce, dairy, meats, breads
                          and other delicious and healthy items to your doorstep.&lt;/p&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;div id="indexRightColumn"&gt;
                  &lt;c:forEach var="category" items="${categories}"&gt;
                      &lt;div class="categoryBox"&gt;
                          &lt;a href="category?${category.id}"&gt;
                              &lt;span class="categoryLabel"&gt;&lt;/span&gt;
                              &lt;span class="categoryLabelText"&gt;${category.name}&lt;/span&gt;
  
                              &lt;img src="${initParam.categoryImagePath}${category.name}.jpg"
                                   alt="${category.name}" class="categoryImage"&gt;
                          &lt;/a&gt;
                      &lt;/div&gt;
                  &lt;/c:forEach&gt;
              &lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>hi is the error message from the glassfish 3+ server</p>
  
  <pre><code>WARNING: StandardWrapperValve[jsp]: PWC1406: Servlet.service() for servlet jsp threw exception
  org.apache.jasper.JasperException: /index.jsp(9,0) PWC5988: Page directive: illegal to have multiple occurrences of 'contentType' with different values (old: text/html; charset=UTF-8, new: text/html)
      at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:81)
      at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:376)
      at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:204)
      at org.apache.jasper.compiler.Validator$DirectiveVisitor.visit(Validator.java:173)
      at org.apache.jasper.compiler.Node$PageDirective.accept(Node.java:600)
      at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2297)
      at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2347)
      at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2353)
      at org.apache.jasper.compiler.Node$Root.accept(Node.java:499)
      at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2297)
      at org.apache.jasper.compiler.Validator.validate(Validator.java:1826)
      at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:223)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
      at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:625)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:473)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:377)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
      at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
      at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
      at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
      at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
      at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
      at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
      at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
      at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
      at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
      at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
      at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
      at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
      at java.lang.Thread.run(Thread.java:722)
  
  WARNING: StandardWrapperValve[jsp]: PWC1406: Servlet.service() for servlet jsp threw exception
  org.apache.jasper.JasperException: /index.jsp(9,0) PWC5988: Page directive: illegal to have multiple occurrences of 'contentType' with different values (old: text/html; charset=UTF-8, new: text/html)
      at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:81)
      at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:376)
      at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:204)
      at org.apache.jasper.compiler.Validator$DirectiveVisitor.visit(Validator.java:173)
      at org.apache.jasper.compiler.Node$PageDirective.accept(Node.java:600)
      at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2297)
      at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2347)
      at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2353)
      at org.apache.jasper.compiler.Node$Root.accept(Node.java:499)
      at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2297)
      at org.apache.jasper.compiler.Validator.validate(Validator.java:1826)
      at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:223)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
      at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:625)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:473)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:377)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
      at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
      at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
      at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
      at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
      at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
      at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
      at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
      at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
      at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
      at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
      at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
      at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
      at java.lang.Thread.run(Thread.java:722)
  
  WARNING: StandardWrapperValve[jsp]: PWC1406: Servlet.service() for servlet jsp threw exception
  org.apache.jasper.JasperException: /index.jsp(9,0) PWC5988: Page directive: illegal to have multiple occurrences of 'contentType' with different values (old: text/html; charset=UTF-8, new: text/html)
      at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:81)
      at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:376)
      at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:204)
      at org.apache.jasper.compiler.Validator$DirectiveVisitor.visit(Validator.java:173)
      at org.apache.jasper.compiler.Node$PageDirective.accept(Node.java:600)
      at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2297)
      at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2347)
      at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2353)
      at org.apache.jasper.compiler.Node$Root.accept(Node.java:499)
      at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2297)
      at org.apache.jasper.compiler.Validator.validate(Validator.java:1826)
      at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:223)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
      at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:625)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:473)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:377)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
      at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
      at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
      at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
      at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
      at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
      at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
      at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
      at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
      at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
      at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
      at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
      at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
      at java.lang.Thread.run(Thread.java:722)
  </code></pre>
  
  <p>Any suggestion is appreciated</p>