• 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

import package problems??

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
i have the foloowing jsp and bean files.
when i use
<jsp:useBean id="mybean" class="beans.StringBean" />
it works fine,because my bean it is in beans directory under classes directory(Tomcat3.1).
but when i use
<%@ page import="beans.*" %>
<jsp:useBean id="myBean" class="StringBean" />
i got an error message that says casnnot load stringBean class. Here are both files
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;
}
}
//============================
jsp file :
<jsp:useBean id="MyBean" class="beans.StringBean" />
<jsp:setProperty name="MyBean" property="message" value="hello world" />
<b><jsp:getProperty name="MyBean" property="message" /></b>
 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This may be way offbase, but make sure there are no upper/lower case typo's in your code like there were in your post.


casnnot load stringBean class

 
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"darine",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please choose a new name which meets the requirements.
Thanks.
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Just like JAVA, JSP is case sentitive. According to the code, it should have two different instance of "beans.StringBean". One is "mybean", another one is "myBean". Maybe even you import the package, jsp still require you to use the full class name includes the whole package for the "class=?".
 
Pay attention! 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