• Post Reply Bookmark Topic Watch Topic
  • New Topic

Setting Bean in Session, reading in JPS, usdBean does not work

 
Markus Schmider
Ranch Hand
Posts: 136
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I want to set a Java Bean in a servlet, and read in in a JSP after forward:
Servlet

JSP


The scriptlet section works, the useBean does not. When a Customer object is bound to the session, the code within useBean is never executed.
What's wrong???

Many thanks
 
Markus Schmider
Ranch Hand
Posts: 136
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok found out the solution myself:
It is wrong to place content within the <jsp:useBean> tag.
 
J. Kevin Robbins
Bartender
Posts: 1801
28
Chrome Eclipse IDE Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
UseBean is outdated, as is putting Java code in jsp files. The correct way to do this is to put the data in scope and use EL/JSTL to display the data. Respond if you are interested in learning the modern way to do this.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65518
105
IntelliJ IDE Java jQuery Mac Mac OS X
 
Stefan Evans
Bartender
Posts: 1822
10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> It is wrong to place content within the <jsp:useBean> tag.

Just to clarify this. It isn't "wrong" per se, just not what you wanted. From memory, anything nested within the useBean tag is executed if (and only if) the page needs to instantiate the bean.
In your case the bean was already instantiated, so it skipped the nested code.

However as has already been pointed out, the introduction of EL made the jsp bean/property tags obsolete.



 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!