Copyright (c) SEMM NL All rights reserved.
Author : Paul Hamaker. Part of

We want to use this bean in our .jsp.

The proper directive,

containing the class' full name.

The reference variable's name for the instance of the bean that's created for us automatically by the generated servlet.

Like all other beans, this one needs a default constructor, too,...

so it can be instantiated without arguments.

Here we initialize its property.

We want the bean instance to live as long as the user session.

By using jsp:getProperty

for the component's property strhex,

the corresponding get-method is called.

It's a lot easier to use the EL alternative here instead.

A bean's methods can be called directly, too.


Setting a bean's property to the value of an expression. Data types must match !

A bean containing properties that match the JSP's parameters by names, has those properties filled with the parameter values. Parameter values are Strings and can only be converted to
byte, int, long, float, double, boolean, char .


Using beans for the business logic, you can let your jsp's do the presentation only. This is widely preferred to having Java code in the JSP, because it is believed that non-programmers should be able to do JSP building and maintenance.




Don't forget this, for a bean's default scope is page, which makes it very short-lived, because in that case, when the page is sent to the user, the bean instance dies.


EL could be used as attribute value instead.


In the JSTL lesson you can see how this is done using the JSTL 'set' tag.