• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp action

 
geet kaur
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

can anyone please
<jsp:usebean id="what shud be the value here??" the name of the attribute which we defined in the servlet class ??and will this create the bean object?>
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you even using <jsp:useBean> in the first place?

If you have set the scoped variable in the servlet controller, you can just access it by name directly.

For example, if in your servlet controller you wrote:
You can access this in the JSP via: ${message}

The same thing works for objects like beans. If you name the scoped variable myBean, for example, and it has a property accessor such as getWhatever(), that property can be accessed via: ${myBean.whatever}

The useBean action does not need to be used to enable such access.
 
geet kaur
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no i am just going through the scriptless jsp!!(head first) just wanted to know what exactly is happening behind
 
Stefan Evans
Bartender
Posts: 1784
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With JSP the tags get translated into java code

<jsp:useBean id="myBean" class="com.mypackage.MyBean"/>

gets roughly translated into java as



So you get a scriptlet variable declared on the page.
If the value already exists as an attribute, it will use that value, otherwise it creates a new object.
Full details available in the jsp reference

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic