File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes import package problems?? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "import package problems??" Watch "import package problems??" New topic
Author

import package problems??

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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

Joined: Oct 21, 2000
Posts: 3901
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


I never took notes in college. That's how I got a 4.0 the first 2 years, and a 3.5 the second two years.
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6913
"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.

A Convergent Visionary ~ Frank's Punchbarrel Blog ~ LinkedIn profile
ken chou
Ranch Hand

Joined: Feb 08, 2001
Posts: 68

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=?".
 
 
subject: import package problems??
 
Threads others viewed
import package problem???
Where in Tomcat3.1 should i put .jsp files, .java files(Beans files)
classpath or package problems?
Error - Please Help!!!
Setting up directory structure for Bean Component in JSP
developer file tools