• Post Reply Bookmark Topic Watch Topic
  • New Topic

Accessing user-defined java classes from JSP  RSS feed

 
Timbu Buddu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a 2 user-defined java classes MenuObj and Queue.
Both of these classes have no access modifiers defined.
I defined these classes in a file called ClassDefs.java.
The first line of this file is ...
package classDefPkg;
I put this file in a folder called classDefPak.
Now I'm trying to access it in a JSP file using...
<%@page language="java" import="classDefPkg.*,java.sql.*,java.util.*" errorPage="ErrorPage.jsp" %>
But it gives me the following error...
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 9 in the jsp file: /jspfiles/tree.jsp
Generated servlet error:
[javac] Compiling 1 source file
C:\Tomcat\work\Standalone\localhost\Tree\jspfiles\tree_jsp.java:7: classDefPkg.MenuObj is not public in classDefPkg; cannot be accessed from outside package
import classDefPkg.MenuObj;
^
C:\Tomcat\work\Standalone\localhost\Tree\jspfiles\tree_jsp.java:8: classDefPkg.Queue is not public in classDefPkg; cannot be accessed from outside package
import classDefPkg.Queue;
^
Can anyone please solve this?
Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both of these classes have no access modifiers defined.

Which naturally makes the inaccessible to the web application. Try declaring them public.
hth,
bear
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!