Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to add beans to JSP

 
jeyaveera pandian
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • 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
 
Brett Knapik
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
P SOLAIAPPAN
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic