944,165 Members | Top Members by Rank

Ad:
  • JSP Discussion Thread
  • Unsolved
  • Views: 4472
  • JSP RSS
Apr 11th, 2007
0

how to call javabean from jsp

Expand Post »
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.................
Similar Threads
Reputation Points: 9
Solved Threads: 0
Light Poster
push is offline Offline
33 posts
since Apr 2007
Apr 13th, 2007
0

Re: how to call javabean from jsp

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,
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
rgtaylor is offline Offline
83 posts
since Mar 2007
Apr 18th, 2007
0

Re: how to call javabean from jsp

thank u sir, 4 u r timely replay.............

Click to Expand / Collapse  Quote originally posted by rgtaylor ...
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,
Reputation Points: 9
Solved Threads: 0
Light Poster
push is offline Offline
33 posts
since Apr 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JSP Forum Timeline: running servlets
Next Thread in JSP Forum Timeline: Logging





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC