• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

How to add beans to JSP

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,
I found problem in adding beans to JSPs. My problem is, for instance, if I want to add the Juggler bean which is in a file named "juggler.jar" using the <jsp:useBean> tag I am not able to do it. plz tell me the way how to use a bean in JSP
Anbudan
K.Jeyaveerapandian
 
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try it without the .jar and the class name. it might work or it is not in the right directory of your application server.
------------------
I wish there was a button on my monitor to turn up the intellegince.
Theres a button called 'brightness' but it doesn't work
 
jeyaveera pandian
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi friend,
Thankyou for your help. But still I am having problems. As i had specified the .class name of the bean instead of the .jar file also I am not able to use that bean. I am using Java Web Server. So. plz tell me where to put my bean in my server's directory? and tell me what to put, the .class file or the .jar file?
Please help me as soon as possible,
Anbudan,
K.Jeyaveerapandian.
 
Brett Knapik
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know about jws very much you will have to look for information on where to place your bean in the documentation on sun's website.
------------------
I wish there was a button on my monitor to turn up the intellegince.
Theres a button called 'brightness' but it doesn't work
 
jeyaveera pandian
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi friends,
Without referring anything, I found how to use bean in JSPs. That is I put my bean's .class file in the same directory of my .jsp file and I used the <%@ import="beanClassName"%> tag before my jsp:useBean tag. In my jsp:useBean tag I wrote like this
<jsp:useBean id="myBean" scope="session" class="beanClassName"/>
I want to know whether this is a proper way or not?! Help me please
Anbudan
K.Jeyaveerapandian
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Anbudan,
I have been working on JSP for couple of months and have noticed that if your bean class is in a package then you don't need to explicitly import it but if it is not in a package then you need to give the following tag:
<%@ page import="beanClassName" %>
 
jeyaveera pandian
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mathur,
Thanks for your answer. But am still having some doubts. If I am having my beanClass in a package how to call it?
One more personal infromation to you! "Anbudan" is not my name. It means "with love". Anbudan is a word in the language Tamil.
Thanks in advance
Anbudan
K.Jeyaveerapandian
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Pandian,
You can keep your jar file in classpath sothat the servlet engine can search it or you can keep it where your application keeps all your servlets class files. Like "servlet.jar" you can include your "*.jar" file in classpath in autoexec.bat file.
for example say your bean class is in "bean.jar" which is in d:\beanjars dir then
set classpath=%classpath%;d:\beanjars\bean.jar
Then your JSP engine will search bean.jar also(apart from other classpaths mentioned) for your class file which you are using in <jsp:useBean ........class="..." />
solaiappan
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic