• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

classpath or package problems?

 
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
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;
}
}
 
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try finding out from the compiled jsp's .java code. It could be problem with the package definition rather than classpath.
 
darine darine
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply.
How and where do we can check out the jsp's java code?
however i've checked almost everyword and i've changed even the bean and the jsp file too,i still getting the same message that says can't load the class stringBean.
thanks again.
 
darine darine
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply.
How and where do we can check out the jsp's java code?
however i've checked almost everyword and i've changed even the bean and the jsp file too,i still getting the same message that says can't load the class stringBean.
thanks again.
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
work directory
Try to do this:

//=================
<%@ page import="beans.*" %>
<jsp:useBean id="stringBean"
class="beans.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:
//==========================
package beans;
public class StringBean
{
private String message="No message specified ";
public void setMessage(String message)
{
this.message=message;
}
public String getMessage()
{
return this.message;
}
}

[This message has been edited by paul sun (edited March 09, 2001).]
 
darine darine
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thnaks for your time,it works the way you said,but it works even without the page directive.
My question is if i do not put " package beans;" in my stringBean.java file,can i use that directive as above"<%@ page import="beans.*" %>
and the i use the action <jsp:useBean id="stringBean" class="stringBean" />
can i do that?
thanks for your time again.
 
paul sun
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Either
"<%@ page import="beans.*" %>
<jsp:useBean id="stringBean" class="stringBean" />
or
<jsp:useBean id="stringBean" class="beans.stringBean" />
is ok.
But "package beans;" must appear in the "stringBean.java" file. If not, the compiled jsp (or servlet) can not find the "stringBean.class" via the class path search.
Compile "stringBean.java" without "package beans;" in the java file, and put the class file in the /web-inf/classes, and then use
<jsp:useBean id="stringBean" class="stringBean" /> without directive. See what you get.

Originally posted by darine darine:
Thnaks for your time,it works the way you said,but it works even without the page directive.
My question is if i do not put " package beans;" in my stringBean.java file,can i use that directive as above"<%@ page import="beans.*" %>
and the i use the action <jsp:useBean id="stringBean" class="stringBean" />
can i do that?
thanks for your time again.



[This message has been edited by paul sun (edited March 09, 2001).]
 
For my next feat, I will require a volunteer from the audience! Perhaps this tiny ad?
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic