Search code examples
javajspeclipse-mars

Jsp showing error


I am getting the error in my eclipse mars. It won't show any pop up for that these errors. And I am able to successfully run even after the errors, though in this particular case that that is also a issue.

  1. I had to run my server again and again, it's not picking up changes.
  2. Why these red squiggly line.
  3. I am getting below error when trying to run this.

    Why red flags

Error:

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 13 in the jsp file: /HelloWorld.jsp
Date cannot be resolved to a type
10: 
11: <%
12: 
13: Date today = new java.util.Date();
14: 
15: String text = "Today's date is: " + today.toString();
16: %>

Solution

  • You need to import date-class or fully qualify both.

    Either put this at the top of your page:

    <%@ page import="java.util.Date" %>
    ....
    Date today = new Date();
    

    or:

    java.util.Date today = new java.util.Date();