将java类导入JSP

发布于 2024-12-06 19:16:20 字数 2681 浏览 0 评论 0原文

这就是问题所在。

我使用 NetBeans 7Tomcat 7hsqldb 开发了一个 Web 应用程序;在我的桌面上一切正常。

当我将 java 文件(.class、.jsp 和 .jar 包)上传到我的站点并尝试加载一个 jsp 页面时,该页面导入包中包含的类(包 中的类 FunzioniSessione it.swlab.util),我收到以下错误:

org.apache.jasper.JasperException: Unable to compile class for JSP:  
An error occurred at line: 6 in the generated java file 
Only a type can be imported. it.swlab.util.FunzioniSessione resolves to a package 

An error occurred at line: 7 in the jsp file: /index.jsp 
FunzioniSessione cannot be resolved to a type 
4: <% 
5: synchronized(this) 
6: { 
7: FunzioniSessione funzioniSessione = new FunzioniSessione(); 
8: String percorso = config.getServletContext().getRealPath("/"); 
9: funzioniSessione.inizializza(session,request,response,percorso,"infocar"); 
10: boolean connesso = session.getAttribute("utenteConnesso") != null; 

An error occurred at line: 7 in the jsp file: /index.jsp 
FunzioniSessione cannot be resolved to a type 
4: <% 
5: synchronized(this) 
6: { 
7: FunzioniSessione funzioniSessione = new FunzioniSessione(); 
8: String percorso = config.getServletContext().getRealPath("/"); 
9: funzioniSessione.inizializza(session,request,response,percorso,"infocar"); 
10: boolean connesso = session.getAttribute("utenteConnesso") != null; 

Stacktrace: 
 org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:93) 
 org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330) 
 org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:451) 
 org.apache.jasper.compiler.Compiler.compile(Compiler.java:328) 
 org.apache.jasper.compiler.Compiler.compile(Compiler.java:307) 
 org.apache.jasper.compiler.Compiler.compile(Compiler.java:295) 
 org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:565) 
 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:309) 
 org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308) 
 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259) 
 javax.servlet.http.HttpServlet.service(HttpServlet.java:729) 

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.33 logs. 

为了防止出现一些明显的答案,我添加了一些更多信息:

  1. 包含类 FunzioniSessione 的包(名为 funzioniComuni.jar)位于WEB-INF\lib 文件夹
  2. 我无法按照堆栈跟踪中的注释查看日志,因为我无权访问提供商的 Tomcat 服务器的日志文件夹。 3 导入指令为 <%@page import="it.swlab.util.FunzioniSessione"%> 我也尝试过使用“;”最后 (<%@page import="it.swlab.util.FunzioniSessione;"%>) 但没有成功。

我等待一些建议。

谢谢

That's the problem.

I developed a web app with NetBeans 7, Tomcat 7 and hsqldb; on my desktop all is Ok.

When I upload my java files (.class, .jsp and .jar packages) to my site and try to load a jsp page which imports a class contained in a package (class FunzioniSessione in package it.swlab.util), I get the following error:

org.apache.jasper.JasperException: Unable to compile class for JSP:  
An error occurred at line: 6 in the generated java file 
Only a type can be imported. it.swlab.util.FunzioniSessione resolves to a package 

An error occurred at line: 7 in the jsp file: /index.jsp 
FunzioniSessione cannot be resolved to a type 
4: <% 
5: synchronized(this) 
6: { 
7: FunzioniSessione funzioniSessione = new FunzioniSessione(); 
8: String percorso = config.getServletContext().getRealPath("/"); 
9: funzioniSessione.inizializza(session,request,response,percorso,"infocar"); 
10: boolean connesso = session.getAttribute("utenteConnesso") != null; 

An error occurred at line: 7 in the jsp file: /index.jsp 
FunzioniSessione cannot be resolved to a type 
4: <% 
5: synchronized(this) 
6: { 
7: FunzioniSessione funzioniSessione = new FunzioniSessione(); 
8: String percorso = config.getServletContext().getRealPath("/"); 
9: funzioniSessione.inizializza(session,request,response,percorso,"infocar"); 
10: boolean connesso = session.getAttribute("utenteConnesso") != null; 

Stacktrace: 
 org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:93) 
 org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330) 
 org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:451) 
 org.apache.jasper.compiler.Compiler.compile(Compiler.java:328) 
 org.apache.jasper.compiler.Compiler.compile(Compiler.java:307) 
 org.apache.jasper.compiler.Compiler.compile(Compiler.java:295) 
 org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:565) 
 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:309) 
 org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308) 
 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259) 
 javax.servlet.http.HttpServlet.service(HttpServlet.java:729) 

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.33 logs. 

To prevent some obvious answers, I add some more information:

  1. The package containing the class FunzioniSessione (named funzioniComuni.jar) is in the WEB-INF\lib folder
  2. I can't look at the logs as the note in the stacktrace suggests, because I have no access to the logs folder of my provider's Tomcat server.
    3 The directive for the import is <%@page import="it.swlab.util.FunzioniSessione"%> I tried also with a ";" at the end (<%@page import="it.swlab.util.FunzioniSessione;"%>) but with no success.

I wait for some suggestions.

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挖鼻大婶 2024-12-13 19:16:20

FunzioniSessione 在您的类路径中吗?一般来说,我们将类保存在已经在 onclasspth 中的 web-inf\classes 中。您能否确保部署目录具有这种结构,并且您的类位于预期的包中?

Is the FunzioniSessione on you classpath ? Generally we keep the classes in web-inf\classes which is already onclasspth. Can you ensure the deployment directory has this structure with you class in expected package ?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文