I am having a problem with errors such as:
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 9 in the generated java file
Only a type can be imported. com.test.util.ConnectionManager resolves to a package
An error occurred at line: 31 in the jsp file: /test.jsp
EmployeeDAO cannot be resolved to a type
28: <td>Job Title</td>
29: <td>Hire Date</td>
30: </tr>
31: <% EmployeeDAO em = new EmployeeDAO();
32: Connection ct = ConnectionManager.getInstance().getConnection();
33: ResultSet rs = em.selectByFirstNameRS(empN,ct);
34: try {
An error occurred at line: 31 in the jsp file: /test.jsp
EmployeeDAO cannot be resolved to a type
28: <td>Job Title</td>
29: <td>Hire Date</td>
30: </tr>
31: <% EmployeeDAO em = new EmployeeDAO();
32: Connection ct = ConnectionManager.getInstance().getConnection();
33: ResultSet rs = em.selectByFirstNameRS(empN,ct);
34: try {
An error occurred at line: 32 in the jsp file: /test.jsp
ConnectionManager cannot be resolved
29: <td>Hire Date</td>
30: </tr>
31: <% EmployeeDAO em = new EmployeeDAO();
32: Connection ct = ConnectionManager.getInstance().getConnection();
33: ResultSet rs = em.selectByFirstNameRS(empN,ct);
34: try {
35: if(rs != null) {%>
An error occurred at line: 53 in the jsp file: /test.jsp
ConnectionManager cannot be resolved
50: } catch (Exception e) {
51: e.printStackTrace();
52: } finally {
53: ConnectionManager.getInstance().releaseConnection(ct);
54: }%>
55: </table>
56: <a href="index.html">Return to search</a>
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:321)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
Note The full stack trace of the root cause is available in the Apache Tomcat/6.0.33 logs.
--------------------------------------------------------------------------------
Apache Tomcat/6.0.33
I was looking through google and it may be caused by not having packages inside the WEB-INF folder. I am running tomcat through IntelliJ IDEA and I’m wondering shouldn’t it move packages that are already in the filepath to the created WEB-INF folder on its own? And if it does, what am I doing wrong? This is the two files I’m using:
index.html:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Employee Test Webapp</title>
</head>
<body>
<h3>Employee Database:</h3>
<table>
<tr>
What is the name of the Employee you want to find?
</tr>
<tr>
<form action="test.jsp" method="post">
<td><input type="text" name="empName"></td>
<td><input type="submit" value="search"></td>
</form>
</tr>
</table>
</body>
</html>
And test.jsp:
<%@ page import="com.sun.xml.internal.ws.wsdl.writer.document.xsd.Import" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.test.dao.*" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="com.test.util.ConnectionManager" %>
<%@ page import="java.sql.ResultSet" %>
<% String empN = request.getParameter("empName"); %>
<html>
<head><title>Employee Test Web App</title></head>
<body>
Your results are:
<table cellpadding="15" border="1" style="background-color: #ffffcc;">
<tr>
<td>Employee ID</td>
<td>First Name</td>
<td>Last Name</td>
<td>Company Name</td>
<td>Department Name</td>
<td>Job Title</td>
<td>Hire Date</td>
</tr>
<% EmployeeDAO em = new EmployeeDAO();
Connection ct = ConnectionManager.getInstance().getConnection();
ResultSet rs = em.selectByFirstNameRS(empN,ct);
try {
if(rs != null) {%>
<%while (rs.next()) {%>
<tr>
<td><%=rs.getInt(1)%></td>
<td><%=rs.getString(2)%></td>
<td><%=rs.getString(3)%></td>
<td><%=rs.getString(4)%></td>
<td><%=rs.getString(5)%></td>
<td><%=rs.getString(6)%></td>
<td><%=rs.getString(7)%></td>
</tr><%
}
}else{
%> <tr>Table empty</tr> <%
}
} catch (Exception e) {
e.printStackTrace();
} finally {
ConnectionManager.getInstance().releaseConnection(ct);
}%>
</table>
<a href="index.html">Return to search</a>
</body>
</html>
Some imports Idea made on its own. Here’s my filepath:
https://i.stack.imgur.com/nJqQq.png
Please help.
Project Structure was right and intellij took care of everything. The resolve error was product of an inner runtime error that had to be corrected first. I used the tomcat logs in order to find it. Thanks for all your help either way.