• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Internal Servlet Error ?

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all
i have a very simple jsp that access a javabean.
my jsp file is in the default directory of tomcat "/weapps/examples/jsp/Box.jsp'
and i have the bean in "/examples/web-inf/classes/Box.java"
my full error is :
" org.apache.jasper.JasperException: Unable to compile C:\jakarta-tomcat-3.3.1\work\DEFAULT\examples\jsp\Box_1.java:50: Class jsp.Box not found.
out.print((new Box().result()));
"
my code are :
==============================
Box.java
public class Box
{
public String result()
{
return "hello world";
}

}
===============================
box.jsp
<%=(new Box().result())%>
 
Ranch Hand
Posts: 1072
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A Bean needs to be in a package.
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,the bean should be in package and the corresponding class file should be under web-inf/classes/packagename/Box.class,not ur Box.java as u did earlier
bye
Dev
 
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by ersin eser:
A Bean needs to be in a package.


I don't think so .... I have often used beans which were not a part of any package and have successfully deployed them in Weblogic 5.1 and WebLogic 6. However the bean class needs to be imported with the jsp directive
<%@ page import="MyBean" %>
 
Shubhrajit Chatterjee
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Shubhrajit Chatterjee:

I don't think so .... I have often used beans which were not a part of any package and have successfully deployed them in Weblogic 5.1 and WebLogic 6. However the bean class needs to be imported with the jsp directive
<%@ page import="MyBean" %>


This is what I found from Servlet 2.3 specification. It never mentions that one is not allowed to put a bean outside a package


SRV.9.5 Directory Structure
A web application exists as a structured hierarchy of directories. The root of this
hierarchy serves as the document root for files that are part of the application. For
example, for a web application with the context path /catalog in a web container,
the index.html file at the base of the web application hierarchy can be served to
satisfy a request from /catalog/index.html. The rules for matching URLs to
context path are laid out in Chapter SRV.11. Since the context path of an application
determines the URL namespace of the contents of the web application, web
containers must reject web applications defining a context path could cause
potential conflicts in this URL namespace. This may occur, for example, by
attempting to deploy a second web application with the same context path, or two
web applications where one context path is a substring of the other. Since requests
are matched to resources case sensitively, this determination of potential conflict
must be performed case sensitively as well.
1. See the JavaServer Pages specification available from http://
java.sun.com/products/jsp.ഊDirectory Structure 61
A special directory exists within the application hierarchy named �WEB-INF�.
This directory contains all things related to the application that aren�t in the
document root of the application. The WEB-INF node is not part of the public
document tree of the application. No file contained in the WEB-INF directory may
be served directly to a client by the container. However, the contents of the WEB-
INF directory are visible to servlet code using the getResource and
getResourceAsStream method calls on the ServletContext. Hence, if the
Application Developer needs access, from servlet code, to application specific
configuration information that he does not wish to be exposed to the web client, he
may place it under this directory. Since requests are matched to resource
mappings case-sensitively, client requests for �/WEB-INF/foo�, �/WEb-iNf/foo�,
for example, should not result in contents of the web application located under /
WEB-INF being returned, nor any form of directory listing thereof.
The contents of the WEB-INF directory are:
� The /WEB-INF/web.xml deployment descriptor.
� The /WEB-INF/classes/ directory for servlet and utility classes. The classes
in this directory must be available to the application class loader.
� The /WEB-INF/lib/*.jar area for Java ARchive files. These files contain
servlets, beans, and other utility classes useful to the web application. The web
application class loader must be able to load classes from any of these archive
files.
The web application classloader must load classes from the WEB-INF/ classes
directory first, and then from library JARs in the WEB-INF/lib directory.
SRV.9.5.1 Example of Application Directory Structure
The following is a listing of all the files in a sample web application:
/index.html
/howto.jsp
/feedback.jsp
/images/banner.gif
/images/jumping.gif
/WEB-INF/web.xml
/WEB-INF/lib/jspbean.jar
/WEB-INF/classes/com/mycorp/servlets/MyServlet.class
/WEB-INF/classes/com/mycorp/util/MyUtils.class


[ June 03, 2002: Message edited by: Shubhrajit Chatterjee ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic