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

JSP displaying a Javabean

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

 
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I like you because you always keep good, crunchy cereal in your pantry. This tiny ad agrees:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic