• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

import package problems??

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • 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>
 
Randall Twede
Ranch Hand
Posts: 4481
3
Java Python Scala
  • Mark post as helpful
  • send pies
  • 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
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • 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.
 
ken chou
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • 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=?".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic