title: Getting error in JSP compilation: "Syntax error on token "import", Name expected after this token"
body: <p>Error is </p>
  
  <blockquote>
    <p>SEVERE: Servlet.service() for servlet [jsp] in context with path [/helloworld] threw exception [Unable to compile class for JSP: </p>
    
    <p>An error occurred at line: [28] in the generated java file: [F:\JAVA
    EE
    project.metadata.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\helloworld\org\apache\jsp\game_jsp.java]
    Syntax error on token "import", Name expected after this token</p>
    
    <p>Stacktrace:] with root cause
    org.apache.jasper.JasperException: Unable to compile class for JSP: </p>
    
    <p>An error occurred at line: [28] in the generated java file: [F:\JAVA
    EE
    project.metadata.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\helloworld\org\apache\jsp\game_jsp.java]
    Syntax error on token "import", Name expected after this token</p>
  </blockquote>
  
  <p>Stacktrace:</p>
  
  <pre><code>at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
      at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:213)
      at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:458)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:389)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:361)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:345)
      at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:603)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
      at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
      at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:501)
      at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
      at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:754)
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1376)
      at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>my code is (NewFile.jsp):</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
  &lt;%@ page import="java.io.*,java.util.*, javax.servlet.*" %&gt;    
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h1&gt;Hii i am sumit. (Welcome to JSP)&lt;/h1&gt;
  &lt;form name="myform" action="game.jsp" method="post" enctype="multipart/form-data"&gt;
      Specify your name:&lt;br /&gt;
        &lt;input type="text" name="name" size="15"/&gt;&lt;br /&gt;
    Specify your Image:&lt;br /&gt;
      Specify your File:&lt;br /&gt;
      &lt;input type="submit" name="Submit" value="Submit your files"/&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>(game.jsp) :</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
      
     &lt;%@ page import="org.apache.commons.fileupload.*"%&gt;
  &lt;%@ page import="org.apache.commons.fileupload.servlet.*"%&gt;
  &lt;%@ page import="org.apache.commons.fileupload.disk.*"%&gt;
  &lt;%@ page import="org.apache.commons.fileupload.util.*"%&gt;
   &lt;%@ page import="org.apache.commons.io.*"%&gt;
  &lt;%@ page import="org.apache.commons.io.filefilter.*"%&gt;
  &lt;%@ page import="org.apache.commons.io.input.*"%&gt;
   &lt;%@ page import="org.apache.commons.io.monitor.*"%&gt;
  &lt;%@ page import="org.apache.commons.io.output.*"%&gt;
  &lt;%@ page import="org.apache.commons.io.comparator.*"%&gt;
  &lt;%@ page import="org.apache.commons.io.serialization.*" %&gt;
   &lt;%@ page import="java.io.*,java.util.*, javax.servlet.*," %&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;%
  ServletFileUpload upload = new ServletFileUpload();
  
  //Parse the request
  List&lt;FileItem&gt; multifiles = upload.parseRequest(request);
  try{
  for(FileItem item : multifiles){
    if(item.isFormField()){
     out.println("sumit singh is king");
    }
    else{
     
    }
   }
  }catch(Exception e){
     out.println("sf");
  }
  %&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>