This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes Page directive: illegal to have multiple occurrences of 'contentType Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Page directive: illegal to have multiple occurrences of Watch "Page directive: illegal to have multiple occurrences of New topic
Author

Page directive: illegal to have multiple occurrences of 'contentType

Faisal Abdulai
Greenhorn

Joined: Sep 09, 2012
Posts: 1
I have a JSP page that is suppose to display data using the servlet and session beans.
However when I run the project from the Netbeans project node. I get the error.

org.apache.jasper.JasperException: /index.jsp(9,0) PWC5988: Page directive: illegal to have multiple occurrences of 'contentType' with different values (old: text/html;

below is the JSP page.


below is also the error from the IDE

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)

Any suggestion is welcomed.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

I dropped your page into a Tomcat 6 environment and it ran without issue. I think netbeans is full of crap.

Try running it in a real environment, outside of netbeans.

That said, I always think that superfluous markup should be avoided. I'd just drop the page directive; it isn't doing anything meaningful and just adds extra markup to the JSP.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Page directive: illegal to have multiple occurrences of 'contentType
 
Similar Threads
IllegalStateException when inserting session attribute into a table
Beginners Querylogue!
Maintain a variable across jsp pages
Jsp Error
Exception when i am trying to dispatch the request to a Error Page