Note that there are some explanatory texts on larger screens.

plurals
  1. POHTTP Status 500 on Tomcat / Windows 7
    text
    copied!<p>I'm constantly getting error <strong>HTTP Status 500</strong> for all JSP pages which uses external Java class defined outside JSP pages. Here are the codes</p> <p><em>index.jsp</em></p> <pre><code>&lt;%@page import="mypack.sou" %&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;title&gt;JSP Page&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;Hello World!&lt;/h1&gt; &lt;% sou o=new sou(); int r=o.hi(); out.println(r); %&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><em>sou.java</em> under package <em>mypack</em></p> <pre><code>package mypack; public class sou { public int hi() { return 0; } } </code></pre> <hr> <p>The error:</p> <blockquote> <p>type Exception report</p> <p>"message Unable to compile class for JSP: An error occurred at line: 14 in the generated java file Only a type can be imported. mypack.sou resolves to a package An error occurred at line: 18 in the jsp file: /web/index.jsp sou cannot be resolved to a type 15: <h1>Hello World!</h1> 16: 17: &lt;% 18: sou o=new sou(); 19: int r=o.hi(); 20: out.println(r); 21: %> An error occurred at line: 18 in the jsp file: /web/index.jsp sou cannot be resolved to a type 15: <h1>Hello World!</h1> 16: 17: &lt;% 18: sou o=new sou(); 19: int r=o.hi(); 20: out.println(r); 21: %> Stacktrace:</p> <p>description The server encountered an internal error (Unable to compile class for JSP: An error occurred at line: 14 in the generated java file Only a type can be imported. mypack.sou resolves to a package An error occurred at line: 18 in the jsp file: /web/index.jsp sou cannot be resolved to a type 15: <h1>Hello World!</h1> 16: 17: &lt;% 18: sou o=new sou(); 19: int r=o.hi(); 20: out.println(r); 21: %> An error occurred at line: 18 in the jsp file: /web/index.jsp sou cannot be resolved to a type 15: <h1>Hello World!</h1> 16: 17: &lt;% 18: sou o=new sou(); 19: int r=o.hi(); 20: out.println(r); 21: %> Stacktrace:) that prevented it from fulfilling this request."</p> </blockquote> <hr> <h1>Directory structure</h1> <ul> <li>webapps<br> |<em>app<br> |<strong></em>_ index.jsp<br> |_<em></strong> WEB-INF<br> ......|<strong></em>_</strong> classes<br> .............|<strong>_<em></strong> mypack<br> ....................|<strong></em></strong>_sou.class, test.war, mypack.jar</li> </ul> <hr> <p><strong>System Info:</strong> Win 7 Ultimate X64, Apache Tomcat 7.0.29<br> java version "1.7.0_02"<br> Java(TM) SE Runtime Environment (build 1.7.0_02-b13)<br> Java HotSpot(TM) Client VM (build 22.0-b10, mixed mode, sharing)<br> Tomcat directory has full permission !</p> <hr> <p>I had to move to GlassFish, where the same code works ! But the problem still exist with Tomcat</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload