aspose file tools
The moose likes JSP and the fly likes Accessing user-defined java classes from JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » JSP
Reply Bookmark "Accessing user-defined java classes from JSP" Watch "Accessing user-defined java classes from JSP" New topic
Author

Accessing user-defined java classes from JSP

Timbu Buddu
Greenhorn

Joined: Apr 01, 2003
Posts: 8
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

Joined: Jan 10, 2002
Posts: 56529
    
  14

Both of these classes have no access modifiers defined.

Which naturally makes the inaccessible to the web application. Try declaring them public.
hth,
bear


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Accessing user-defined java classes from JSP
 
Similar Threads
calling javabean from jsp
JSP - Excel using POI
Unable to find class
Why can't I import these classes?
please help with tomcat, javabean and jsp