Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP displaying a Javabean  RSS feed

 
Gerald Spica
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created a javabean that takes the input from a checkbox for 6 different cabs, Cab 1, Cab2, Cab3 etc. I have private variables cab1Counter++ etc., in my bean with associated get and set methods for each cabCounter. I created the below JSP to give me a summary of my inputs.

MY PROBLEM: If I select an item it gets incremented, but on a second pass if the item is not selected it's counter goes back to 0. I cannot come up with a good way to iterate over my string of cab's entered. Anyone have any ideas?

 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gerald,

As state is held in your bean, your bean needs to be persistent between requests. Are you asking how to implement this?

Jules
 
Gerald Spica
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I have gotten lost in the realm of state, I want this bean to persist between requests, without EJB.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Attach it to the session as an attribute. Be sure not to recreate it on each page.
 
Gerald Spica
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It being the bean? I am not sure what you mean. I have a count variable, also private with a get method that increments the count variable ++, and also returns the incremented variable. This works fine. So I am not sure that the state is correct.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!