Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp:useBean statements within if-else

 
Faisal Khan
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am doing the following:

I get the following error: jsp.error.useBean.duplicate
I presume the beans are being created before getting to the if-else statments. Can someone please enlighten me how I can achieve the above other than using separate JSP pages for this purpose.
Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64712
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, that's not allowed. And in any case, remember that useBean is going to create scripting variables for the bean and by nesting them within a block, their scope would be limited to the block.
It's unusual to try an make the same variable of a different type. What are you actually trying to do?
What is the relationship of the two types? Does one extend the other? Do they implement a common interface? If they share no relationship, how would you expect to be able to use the bean in a common fashion on the rest of the page?
 
Faisal Khan
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear,
From my reading around, I realised what I was doing is wrong but not sure of the best solution. The QuoteRecalculateBean extends QuoteBean and overrides two methods.
What I want to do is first time the page is loaded the QuoteBean class should be used, if the user hits recalculate the page gets reloaded and this time it should use QuoteRecalculateBean to work out the new loan.
Would I be better off handling this in my Action class and storing quote in the session, then changing all ${quote.listPrice} etc to ${sessionScop.quote.listPrice} etc.
Do I make sense?
FK
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64712
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that the more processing you do in the action, rather than on the JSP, the easier and clearer it is going to be.
 
Faisal Khan
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks again Bear.
I better get re-writing now.
FK
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic