質問

I am using Tomcat6.0, Eclipse SDE 7.0 Express for Web Developers, and jdk1.6

In my jsp page i have a code that looks like the followeing

<%
List<String> options = new ArrayList<String>();
DynamicCombo comboBox = new DynamicCombo();
options = comboBox.generateComboBox();
Collections.sort(options);
int tempVar = 0;
while (tempVar < options.size()) {
out.print("<option value=\"");
out.print(options.get(tempVar));
out.print("\">");
out.print(options.get(tempVar));
out.print("</option>");
tempVar++;
}
%>

DynamicCombo is a class inside the package com.ems.billGen.util and i am importing this package in the jsp appropriately as :-

<%@page import="com.ems.billGen.util.*" %>

This class DynamicCombo has a method named generateComboBox(), that simply creates a list of strings and returns this string.

When I hover over the class DynamicCombo in the above jsp, i realize that it is well recognized because i get the proper documentation for the class. Please see the screen shot below :- on hovering over the class name in the jsp file

Now when i deploy the above page and view it in firefox, i get the following jasper exception :-

An error occurred at line: 36 in the jsp file: /implementation.jsp

DynamicCombo cannot be resolved to a type
33:     <td><select name="product_list">
34:         <%
35:             List<String> options = new ArrayList<String>();
36:             DynamicCombo co = new DynamicCombo();
37:             options = co.generateComboBox();
38:             Collections.sort(options);
39:             int tempVar = 0;

I am not able to understand the reason, and how to solve this issue. Any inputs are appreciated.

The respective class file is also being generated for DynamicCombo in the web-inf folder of the war file as:- class file is actually present in the generated war file

役に立ちましたか?

解決

The error message says it all, and the screenshot confirms: such class does not exist in the right path.

The problem is subtle: you import com.ems.billGen.util.DynamicCombo, and the path to the class is com/ems/billgen/util/DynamicCombo.class (notice the capital G in package name and the lack thereof in the path name).

Probably it is an error of some of the tooling. The error was triggered by the fact that the naming does not follow Java conventions (which is never to use capital letters in package names).

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top