• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Urgent : Having a doubt , please confirm

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am using a java class/bean class in JSP page as below.
My JSP page has the following :
<jsp:useBean id="id1" class="BeansMultiLang.MultilangPriceHandler" />
String login = request.getParameter("login");
boolean flag = id1.checkLogin(login);
if(flag)
do this
else
do that
*****************************************
Now, I want to confirm one thing :
Whether above code is similar to as
BeansMultiLang.MultilangPriceHandler = new BeansMultiLang.MultilangPriceHandler();
(Like in simple java or servlet class)
What I mean to say is whether new object of above class is made
every time this jsp page is visited or this object is called only once
& shared by all JSP page calls.
Though the methods are synchronized in BeansMultiLang.MultilangPriceHandler class but
still this java class has some class variables which are changed everytime
its methods are called(From JSP page).One variable may be changed by 2 separate methods.
If object is not created for every page, I might be in trouble, because
wrong conclusions can be done then. If new object is created everytime
then its fine.
Can anybody help me out & confirm How beans/java classes objects are
used & interpreted in JSP pages.
I am in the mid of project & stuck up.
Please help..........
Manoj
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have a choice to control the lifetime of the bean object by means of the "scope" attribute used in the jsp:useBean tag.
The default is scope="page" - gives you a new object with every request, only visible inside the JSP
Other values allowed are:
scope="request" - like page but can be forwarded
scope="session" - saved in session
scope="application" - shared by all
Bill
 
reply
    Bookmark Topic Watch Topic
  • New Topic