Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

import package problem???

 
darine darine
Ranch Hand
Posts: 43
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
what the settings of classpath with tomcat3.1 to access classes
directory?is it by default or what?
I have my files in the bottom of this message.
When i append the package name to the class name i do not need to import the package using the page directive. it works fine.
I've tried to put the bean java file in the beans directory under classes directory without "package beans;" statement and I've tried to run my jsp file,I still get the message can't load the bean class.
here my jsp file:
//=================
<%@ page import="beans.*" %>
<jsp:useBean id="stringBean" class="StringBean" />
<%-- <jsp:getProperty name="stringBean" property="message" /> --%
<jsp:setProperty name="stringBean" property="message" value="hello matt from new directories " />
<jsp:getProperty name="stringBean" property="message" /><br>
//===========================
Here is my bean java file:
//==========================
public class StringBean
{
private String message="No message specified ";
public void setMessage(String message)
{
this.message=message;
}
public String getMessage()
{
return this.message;
}
}
 
Revati Pathak
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
there are no special settings of classpath to access classes directory. but if you are putting your class file in classes/bean directory then you must include the statement package bean; in your java file. otherwise it will not be able locate your class file.
this is essential in both the cases whether you import the bean.* using Page directive or directly say <jsp:useBean id="stringBean" class="bean.StringBean" />
hope this will solve your problem.
-Revati
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic