java - Any class I imported cannot resolved to a type in my jsp file with 500 error -
this class want use in jsp:
package com.entity; public class days { private int d; public int getd() { return d; } public void setd(int d) { this.d = d; } public days() { super(); } public days(int d) { super(); this.d = d; } }
this jsp code
<%@page import="org.eclipse.jdt.internal.compiler.ast.foreachstatement"%> <%@ page language="java" contenttype="text/html; charset=utf-8" pageencoding="utf-8" %> <%@ page import="java.io.*, com.entity.days,com.factory.*, net.sf.jasperreports.engine.*, net.sf.jasperreports.engine.util.*, java.util.*,java.sql.*, net.sf.jasperreports.engine.export.*"%> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html> <head> <title></title> <%@ include file="/web-inf/views/include/easyui.jsp"%> <script src="${ctx}/static/plugins/my97datepicker/wdatepicker.js" type="text/javascript"></script> </head> <body style="font-family: '';"> <div id="tb" style="padding:5px;height:auto;font-size:12px;" class="datagrid-toolbar"> <div> <span>report type:</span> <select id="reporttype" class="easyui-combobox" name="dept" > <option value="1">waterlevel</option> <option value="2">rainfall</option> <option value="3">pressure</option> </select> <span class="toolbar-item dialog-tool-separator"></span> <span>month:</span> <input id="db" type="text" name="from" class="easyui-datebox" data-options="width:150,prompt: 'month'"/> <span class="toolbar-item dialog-tool-separator"></span> <a href="" class="easyui-linkbutton" plain="true" iconcls="icon-search" onclick="view()">check</a> </div> </div> <% days days = new days(2); out.println(days.getd()); %> <%-- file reportfile = new file(application.getrealpath("web-inf/views/jasper/successday.jasper")); jasperreport jasperreport = (jasperreport) jrloader.loadobject(reportfile); try{ //java bean jrdatasource datasource = new jrbeancollectiondatasource(daysfactory.get()); jasperreport jasperreport = (jasperreport) jrloader.loadobject(reportfile); jasperprint = jasperfillmanager.fillreport(jasperreport, null, datasource); jrhtmlexporter exporter = new jrhtmlexporter(); exporter.setparameter(jrexporterparameter.jasper_print, jasperprint); exporter.setparameter(jrexporterparameter.output_writer, out); exporter.setparameter(jrhtmlexporterparameter.is_using_images_to_align, boolean.false); exporter.exportreport(); out.flush(); }catch(exception e){ e.printstacktrace(); } --%> <hr> </script> </body> </html>
this error
http status 500 - unable compile class jsp:
[
this stacktrace:
stacktrace: org.apache.jasper.compiler.defaulterrorhandler.javacerror(defaulterrorhandler.java:103) org.apache.jasper.compiler.errordispatcher.javacerror(errordispatcher.java:366) org.apache.jasper.compiler.jdtcompiler.generateclass(jdtcompiler.java:468) org.apache.jasper.compiler.compiler.compile(compiler.java:378) org.apache.jasper.compiler.compiler.compile(compiler.java:353) org.apache.jasper.compiler.compiler.compile(compiler.java:340) org.apache.jasper.jspcompilationcontext.compile(jspcompilationcontext.java:646) org.apache.jasper.servlet.jspservletwrapper.service(jspservletwrapper.java:357) org.apache.jasper.servlet.jspservlet.servicejspfile(jspservlet.java:390) org.apache.jasper.servlet.jspservlet.service(jspservlet.java:334) javax.servlet.http.httpservlet.service(httpservlet.java:728) org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter.java:51)
so, whatever class is, same error is!
you must import class days
jasper
template.
inside jrxml
file looks :
<jasperreport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="yourreport"> <!-- properties --> <import value="com.entity.days"/> <!-- rest body of template --> </jasperreport>
then must compile template com.entity.days
on classpath (in ireport or in jaspersoftstudio). after steps must works!