• 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

when should i need to use beans

 
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here i am developing a webapplication. i am creating a registration form in jsp so in the registraton form there is department list field}(combo box)
so i need to add the elements in the department filed from the database....
there are 2 ways' for doing this...
i can read the fileds from the database and add them to the hastable and then to session,
2nd way is using bean. i will set the values and read them in the jsp file



which is most preferred ???







:roll: :roll: :roll: :roll: :roll:
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use thef first appraoch if you want to preserve the values across pages but if you are using the value only for the form then I would recommend the 2nd approach.
 
saikrishna cinux
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey i need those values only for one form... not in all forms...
so can i use beans...

but , i think, peformance wise Sessions are the best.


:roll:
can any one plzzz tell me according to performance of the application...
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You would define a bean/VO/TO. There you would probably have all the properties present in the form. The combo field should be a collection e.g. ArrayList. Now what you would do is, bind your VO/TO with the request object as attribute and get that in your JSP. Then you just need to manipulate that object.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by saikrishna cinux:
[QB]hey i need those values only for one form... not in all forms...
but , i think, peformance wise Sessions are the best.



How??

We usually use session when its really required to do that. Your work can easily be done with request object. Avoid binding objects to session, which doesn't really qualify for that.
 
saikrishna cinux
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Adeel Ansari:
You would define a bean/VO/TO. There you would probably have all the properties present in the form. The combo field should be a collection e.g. ArrayList. Now what you would do is, bind your VO/TO with the request object as attribute and get that in your JSP. Then you just need to manipulate that object.



thanks for ur reply...
yes, i have used session for displaying the fields in the combobox but i have used vector not ArrayList,,
and some programmmers use HashTable for it..
which is the better among all..

I know that Vector class is synchronized and i thin it takes extra time...


:roll:
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by saikrishna cinux:
yes, i have used session for displaying the fields in the combobox



Session is not the suitable place in this case, as I have mentioned earlier. You had better do it with request object.

As you just need this from one page to another, request object is your best bet. We use session when we need something for the particular session, such as role associated with the current user, etc..


I know that Vector class is synchronized and i thin it takes extra time...



You are right. I would go for ArrayList.
 
saikrishna cinux
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oh thanx Mr ansari....
but what if i use beans in place of request object?
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by saikrishna cinux:
oh thanx Mr ansari....
but what if i use beans in place of request object?



Oh Saikrishna, What do you mean by that?

You are confusing things. Request object and beans are not alternatives. You would add your beans in a collection and then place that collection in your request scope.

Are you gettin me?
[ December 21, 2005: Message edited by: Adeel Ansari ]
reply
    Bookmark Topic Watch Topic
  • New Topic