Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

use bean  RSS feed

 
Arul Jose
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i tried an useBean example


-----------------------example.jsp----------------------------
This is an example jsp page !!

<%@ page import="foo"%>

<jsp:useBean id="ex1" class="foo.exampleBean" />
<jsp:getProperty name="ex1" property="member"/>
--------------------------------------------------------------

i put the .class file of exampleBean.java in WEB-INF/classes/foo

the java file follows

-------------------------exampleBean.java---------------------

public class exampleBean{
private int member;

public int getMember(){
return member;
}

public void setMember(int mem){
member=mem;
}
}

-------------------------------------------------------

i do not know where the problem is.

can anyone help.

ARUL JOSE
[ July 14, 2005: Message edited by: Bear Bibeault ]
 
Arul Jose
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have finally found the error. it was : i didnot say 'package foo;' in the java file. do try this.

java file : the class file should be in WEB-INF/classes/foo/

jsp file : should be in applicationFolder



its working only with packages. i'll find the reason soon, why its not working without using packages. please tell me if you find it.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All classes must be in a package other than the default.
 
Arul Jose
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
to me the default was not working at all. it was working only with packages.

i tried without giving the package name in anything. it showed the 'class not found exception'
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correct, if the class is not in a package, the container will be unable to load it. Package your classes.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!