• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

A JavaBean inside a JSP function

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Iam using a java beans inside a jsp, this how i did that.
<jsp:useBean id="prm" class="xx.Param" scope="session"/>
In the same jsp file iam defining function (doXX()), which call the bean linked by jsp:useBean tag. Iam getting compilation error.
<%!
public String doXX() {
//some code
String ss = prm.getID(); //??? i think this is where the problem is
}
%>
So my doubt is can we use the instance of java beans inside a jsp function???
Thanks in Advance
 
Ranch Hand
Posts: 1934
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It has more to do with compiler not knowing the scope of the names bean class.
Include that package/class at the beginning of your jsp, I think you are all set to go.
Kishore.
 
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jsp:useBean makes the specified scripting variable available in the main body (service method) of the JSP. It will not be available to declarations.
 
Bear Bibeault
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
P.S. Take a look at the java file created by the container on the behalf of your JSP. Much will be revealed.
 
j archie
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Kishore Dandu & Bear Bibeault,
What should I do to make the bean instance available public.
I added the following snippet to my jsp scriptlet
<% thisBean = myUseBean; %>
and declared thisBean in jspdeclarative statement.
<%! MyUseBean thisBean; %>
it seems to be working fine, but is this a correct way. Please help me.
    Bookmark Topic Watch Topic
  • New Topic