how to call javabean from jsp

Reply

Join Date: Apr 2007
Posts: 33
Reputation: push is an unknown quantity at this point 
Solved Threads: 0
push push is offline Offline
Light Poster

how to call javabean from jsp

 
0
  #1
Apr 11th, 2007
how to call javabean from jsp? i wanted to call javabean from jsp with in my own folder keeping at webapps folder. Pleasssssssssssssss help me for this.................
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 83
Reputation: rgtaylor is an unknown quantity at this point 
Solved Threads: 2
rgtaylor rgtaylor is offline Offline
Junior Poster in Training

Re: how to call javabean from jsp

 
0
  #2
Apr 13th, 2007
Push, can you provide a little clearer post with more specific details about what you are trying to do and what the problem is...

typically in JSP you would use the useBean tag to indicate what Bean you want to use...

There are paramters to indicate the class or type of bean to use and scope of the bean and name or id of the bean....

if the bean doesn't already exist in the scope you have indicated, it will be created if you have provided the class parameter, if you only provided the type parameter, it will not create a new one, but only use the existing one, if it exists... so type is useful only if you know the bean already exists in the scope... and you don't want a new one created.... default scope, I believe, is page based, so it will not persist unless you make it a larger scope...

So you call the <JSP:useBean ...> you provide a name/id for the bean and a class for the bean... in the useBean tage you use id="XXX" to give the bean a name and then when you set or get values later you use name="XXX" to indicate the name you gave the bean in its id="XXX" earlier.... this sems strange... when you create the bean, you give it an "id" this id becomes the "name" you used in later tags to refer to the bean... why didn't they jsut make all tags call it name="XXX" or id="XXX" rather thanmixing them.... who knows... in any case be careful of that point....

Scope can be page, request, session or application


the bean file should be in a JAR file and should be in /WEB-INF/lib or be in a folder structure that matches the package structure the folder structure must be sub-folders of /WEB-INF/classes

i.e. /WEB-INF/classes/com/rgtaylor/java/web/beans
or
/WEB-INF/lib/rgtaylorBeans.jar

If your Web Hosting company or SysAdmin doesn't allow you to use those locations, you can not do anything with it really... your only option then is to include the code directly inthe JSP files, which is not a good idea...

if you are asking how to place the files in some other location... unless you hack the server source, you can't... it is coded, for security reasons to require a /WEB-INF/ location... things under this folder can not be directly accessed or referenced from outside your webapp... So I place my main pages under "webapps/myapp", for example, but then all the included stuff, is placed under "webapps/myapps/WEB-INF/"...

Peace,
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 33
Reputation: push is an unknown quantity at this point 
Solved Threads: 0
push push is offline Offline
Light Poster

Re: how to call javabean from jsp

 
0
  #3
Apr 18th, 2007
thank u sir, 4 u r timely replay.............

Originally Posted by rgtaylor View Post
Push, can you provide a little clearer post with more specific details about what you are trying to do and what the problem is...

typically in JSP you would use the useBean tag to indicate what Bean you want to use...

There are paramters to indicate the class or type of bean to use and scope of the bean and name or id of the bean....

if the bean doesn't already exist in the scope you have indicated, it will be created if you have provided the class parameter, if you only provided the type parameter, it will not create a new one, but only use the existing one, if it exists... so type is useful only if you know the bean already exists in the scope... and you don't want a new one created.... default scope, I believe, is page based, so it will not persist unless you make it a larger scope...

So you call the <JSP:useBean ...> you provide a name/id for the bean and a class for the bean... in the useBean tage you use id="XXX" to give the bean a name and then when you set or get values later you use name="XXX" to indicate the name you gave the bean in its id="XXX" earlier.... this sems strange... when you create the bean, you give it an "id" this id becomes the "name" you used in later tags to refer to the bean... why didn't they jsut make all tags call it name="XXX" or id="XXX" rather thanmixing them.... who knows... in any case be careful of that point....

Scope can be page, request, session or application


the bean file should be in a JAR file and should be in /WEB-INF/lib or be in a folder structure that matches the package structure the folder structure must be sub-folders of /WEB-INF/classes

i.e. /WEB-INF/classes/com/rgtaylor/java/web/beans
or
/WEB-INF/lib/rgtaylorBeans.jar

If your Web Hosting company or SysAdmin doesn't allow you to use those locations, you can not do anything with it really... your only option then is to include the code directly inthe JSP files, which is not a good idea...

if you are asking how to place the files in some other location... unless you hack the server source, you can't... it is coded, for security reasons to require a /WEB-INF/ location... things under this folder can not be directly accessed or referenced from outside your webapp... So I place my main pages under "webapps/myapp", for example, but then all the included stuff, is placed under "webapps/myapps/WEB-INF/"...

Peace,
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JSP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC