title: Status 500 – Internal Server Error On Java Servlet
body: <p>I have error as Status 500 – Internal Server Error in my JSP when i try to post request.
  So i need to do http request for creating folder on Dropbox with some name(Test, etc.)
  I have Tomcat 9.0.30 and add jstl-1-2.jar
  i have a Class DropboxActioner as</p>
  
  <pre><code>package ua.oleh.application;
  
  import java.io.BufferedReader;
  import java.io.DataOutputStream;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.net.HttpURLConnection;
  import java.net.MalformedURLException;
  import java.net.URL;
  
  public class DropboxActioner {
      private  String token ="Bearer &lt;my token&gt;";
      public void createFolder(String path) throws Exception {
  
          try {
              URL url = new URL("https://api.dropboxapi.com/2/files/create_folder");
              HttpURLConnection conn = (HttpURLConnection) url.openConnection();
              String parameters = "{\"path\": \"" + path + "\"}";
              conn.setRequestProperty("Content-Type", "application/json");
              conn.addRequestProperty ("Authorization", token);
              conn.setRequestMethod("POST");
              conn.setDoOutput(true);
              DataOutputStream writer = new DataOutputStream(conn.getOutputStream());
              writer.writeBytes(parameters);
              writer.flush();
              if (writer != null)
                  writer.close();
              if (conn.getResponseCode() != 200) {
                  System.out.println(conn.getResponseMessage());
                  throw new RuntimeException("Failed : HTTP error code : "
                          + conn.getResponseCode());
              }
              BufferedReader br = new BufferedReader(new InputStreamReader(
                      (conn.getInputStream())));
              String output;
              System.out.println("Output from Server .... \n");
              while ((output = br.readLine()) != null) {
                  System.out.println(output);
              }
              conn.disconnect();
          } catch (MalformedURLException e) {
  
              e.printStackTrace();
  
          } catch (IOException e) {
  
              e.printStackTrace();
          }
      }
  }
  
  </code></pre>
  
  <p>And if i try it with public static void main it works.
  I need to do this with web page where i need to enter token and folder name.
  For test i don't get this parameters from JSP and write it static in code.
  I have JSP page</p>
  
  <pre><code>
  &lt;%@ page contentType="text/html;charset=UTF-8" language="java" %&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;DropboxDemo&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  Enter token
  &lt;input id ="key"&gt;&lt;/input&gt;
  Enter folder Name
  &lt;input id ="folder_name"&gt;&lt;/input&gt;
  &lt;button id="login"&gt;Login&lt;/button&gt;
  &lt;button id ="create"&gt;Create folder&lt;/button&gt;
  &lt;%@page import="ua.oleh.application.DropboxActioner" %&gt;
  &lt;% DropboxActioner dropboxActioner = new DropboxActioner();%&gt;
  &lt;% String token;%&gt;
  &lt;% String name = request.getParameter("name");%&gt;
  &lt;%= dropboxActioner.createFolder(name)%&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And i get e error on Chrome</p>
  
  <pre><code>Type Exception Report
  
  Message Unable to compile class for JSP:
  
  Description The server encountered an unexpected condition that prevented it from fulfilling the request.
  
  Exception
  
  org.apache.jasper.JasperException: Unable to compile class for JSP: 
  
  An error occurred at line: [18] in the jsp file: [/index.jsp]
  The method print(boolean) in the type JspWriter is not applicable for the arguments (void)
  15: &lt;% DropboxActioner dropboxActioner = new DropboxActioner();%&gt;
  16: &lt;% String token;%&gt;
  17: &lt;% String name = request.getParameter("name");%&gt;
  18: &lt;%= dropboxActioner.createFolder(name)%&gt;
  19: &lt;/body&gt;
  20: &lt;/html&gt;
  
  
  Stacktrace:
      org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
      org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:213)
      org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:519)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:392)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:362)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:346)
      org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:605)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:400)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
      org.apache.jasper.servlet.JspServlet.init(JspServlet.java:139)
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
      org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
      org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:367)
      org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
      org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860)
      org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1598)
      org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
      java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      java.lang.Thread.run(Thread.java:748)
  Note The full stack trace of the root cause is available in the server logs.
  
  </code></pre>
  
  <p>i look a guide on Youtube where programmer get data from method in Java class with</p>
  
  <pre><code>&lt;% DropboxActioner dropboxActioner = new DropboxActioner();%&gt;
  &lt;% String token;%&gt;
  &lt;% String name = request.getParameter("name");%&gt;
  &lt;%= dropboxActioner.createFolder(name)%&gt;
  </code></pre>
  
  <p>But i have an error.
  How i can resolve it?
  Maybe i can only read data from jsp/html to Java class and run it in public static void main and don't connect jsp page with Java class?</p>