Seems to me that you should give it an id that is different from the class name, 
FormBean.getUsername() could be confused for a static method call when it is not.

-----Original Message-----
From: Ron Day [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 11, 2002 2:04 PM
To: Tomcat Users List
Subject: RE: Cannot use bean from jsp, but servlet ok. I'm dying!


Seems like you are mixing jsp action tags and java class instances.

Use <jsp:usebean> with <jsp getpropery>

or

Use import in <@...%> tag and create an instance

-----Original Message-----
From: eric [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 11, 2002 12:18 AM
To: [EMAIL PROTECTED]
Subject: Cannot use bean from jsp, but servlet ok. I'm dying!


Help. Absolutely stuck. Tomcat cannot find my bean classes no matter what
when called from jsp pages. From within servlets no problem.

Here is the jsp
---------------
<%@ include file="pub_hdr.html" %>
<jsp:usebean id="FormBean" class="beans.FormBean" scope="request" />
<form>
<input type="text" name="userName" value="<% =FormBean.getUserName() %>">
<%= FormBean.getErrorMsg("userName") %>
</form>
<%@ include file="pub_ftr.html" %>

Here is the bean
----------------
package beans;
import java.util.*;
import java.io.Serializable;
public class FormBean implements Serializable {
  public String userName;
  public FormBean() {}

  public String getUserName() {
    return this.userName;
  }
  public void setUserName(String uname) {
    this.userName = uname;
  }
}

NO MATTER WHAT, as soon as I access the jsp page. This error comes up.
Generated servlet error: C:\jwsdp-1_0\work\Standard
Engine\localhost\messagesmith\en\users$jsp.java:126: Undefined variable or
class name: FormBean out.print( FormBean.getUserName() );

It certainly seems that TC cannot find the FormBean class which lives here:
C:\jwsdp-1_0\webapps\project\WEB-INF\classes\beans.
I've changed that scope attribute to application or page, but it doesn't
change.
With TC3.x I had to do some configuration in the conf/server.xml file, but
this doesn't seem necessary w/ TC4. All the same I've adding the following
context to the server.xml, but it doesn't help.
<Context path="/project"
  docBase="webapps/project"
  debug="0"
  reloadable="true" />

Anyone have any ideas? It is killing me. Again, I can instantiate the
FormBean class from within servlets, but not from JSP.

Env:
====
Win2k Server, jdk1.4.0_01, TC4.0
Classpath=.;C:\jwsdp-1_0\common\lib\servlet.jar;C:\jwsdp-1_0\webapps\project
\WEB-INF\classes;C:\jfreechart-0.9.1\jars\jcommon-0.6.3.jar;C:\jfreechart-0.
9.1\jars\jfreechart-0.9.1.jar;
TOMCAT_HOME=C:\jwsdp-1_0
CATALINA_HOME=C:\jwsdp-1_0
JAVA_HOME=C:\j2sdk1.4.0_01


--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to