I am learning debugging and I am getting the following error when running tomcat through my browser. I am using Texpad to write and I guess tomcat after.
An error occurred at line: 18 in the jsp file: /Debug.jsp
Date cannot be resolved to a type
15:
16: <%
17: response.setContentType("MIME");
18: Date today = new Date(12,20,2004);
19:
20: Date created = new Date(session.getCreationTime());
21: Date lastAccessed = new Date(session.getLastAccessedTime());
I am getting the same error twice for lines 18, 20, and 21. The original code is below.
<HTML>
<HEAD>
<TITLE>JSP Debugging</TITLE>
</HEAD>
<BODY>
<% import java.io.*; %>
<% import java.util.Date; %>
<% import java.util.Enumeration; %>
<%
response.setContentType("MIME");
Date today = new Date(12,20,2004);
Date created = new Date(session.getCreationTime());
Date lastAccessed = new Date(session.getLastAccessedTime());
out.print("<h1>Today is " );
out.print(today);
out.print("</h1>" );
out.print("This session has the following characteristics:<br>" );
out.println("<br>ID: ");
session.getId(); %>
out.println("Created: " + created);
out.println("Last Accessed: " + lastAccessed);
out.println("<br>Max Inactive Interval: " +
session.getMaxInactiveInterval());
%>
</BODY>
</HTML>
I know there are many more errors and I am working on those but for now any help on this would be amazing. As far as I could tell it is an issue with Date but I am not sure what exactly.
EDIT-------------------------------------------------------------------------------------------------
So I made the changes requested and the code now looks like the following:
<HTML>
<HEAD>
<TITLE>JSP Debugging</TITLE>
</HEAD>
<BODY>
<%@ page import="java.util.Date,java.io.*,java.util.Enumeration"%>
<%
response.setContentType("MIME");
Date today = new Date(12,20,2004);
Date created = new Date(session.getCreationTime());
Date lastAccessed = new Date(session.getLastAccessedTime());
out.print("<h1>Today is " );
out.print(today);
out.print("</h1>" );
out.print("This session has the following characteristics:<br>" );
out.println("<br>ID: ");
session.getId(); %>
out.println("Created: " + created);
out.println("Last Accessed: " + lastAccessed);
out.println("<br>Max Inactive Interval: " +
session.getMaxInactiveInterval());
%>
</BODY>
</HTML>
And after I ran localhost:8080/Debug.jsp in my web browser it downloaded a new copy of the jsp with the expected results but they were supposed to be displayed in the browser.
<HTML>
<HEAD>
<TITLE>JSP Debugging</TITLE>
</HEAD>
<BODY>
<h1>Today is Tue Feb 25 00:00:00 EST 1919</h1>This session has the following characteristics:<br><br>ID:
out.println("Created: " + created);
out.println("Last Accessed: " + lastAccessed);
out.println("<br>Max Inactive Interval: " +
session.getMaxInactiveInterval());
%>
</BODY>
</HTML>