• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

use bean

 
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
That which doesn't kill us makes us stronger. I think a piece of pie wouldn't kill me. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic