InstantOnline Basic 3.0 Beta 1 is now available. The 3.0 version introduces the JSP 1.1 syntax for all InstantOnline Basic components, while still supporting the old SSI syntax so you can migrate to the JSP syntax at your own pace.
When should I use a bean vs. a custom action?
In a complex JSP/Servlet application, would you use both JavaBeans and custom actions or one or the other? It seems like their functionality overlaps quite a bit. |
Answer: Yes, it does and there’s no clear cut answer for when one component type is the “right” choice. Often you end up using both types.I touch on this in the book in a couple of places. In Chapter 8, I say:
An example of what I mean here is a bean with customer information properties and custom actions that process that information. You can use a <jsp:useBean> action to capture the input from a form, and custom actions to validate the captured data and to store it in a database: <jsp:useBean id="custInfo" class="com.mycompany.CustomerInfoBean"> <jsp:setProperty name="custInfo" property="*" /> </jsp:useBean> <mytags:validateCustomerInfo name="custInfo" forwardOnInvalid="input.jsp" /> <mytags:storeCustomerInfo name="custInfo" nextPage="confirm.jsp" /> In Chapter 16 I say:
Hence, a bean that does something (such as the validation and storing above) can be wrapped in a custom action for use in a JSP page, and at the same time be used as is in a servlet or some other Java class. The counter bean and custom actions in Chapter 8 are examples of that. Instead of a bean, a custom action can of course wrap a regular utility class, such as the cookie and string utility classes used in the custom action examples in Chapter 16. |
How can I set a property value of a different type than String?
I have bean with properties that are of other types than String. How can I set these properties using <jsp:setProperty>? How about a non-String attribute value for a custom action? |
Answer: If you use a literal string as the attribute value, such as <jsp:setProperty name="foo" property="bar" value="value1" /> the JSP container looks at the type of the corresponding property in the bean class to see if the value needs to be converted. If the property is of type boolean, Boolean, byte, Byte, char, Character, double, Double, int, Integer, float, Float, long or Long, it will try to convert the string value to the correct type for the property. If the property is a String, the value is of course used as is. If it’s something else, you get a translation-time error. If you need to set a property that is not one of the types listed above, for instance a java.util.Date, you must to use a request-time attribute value in JSP 1.1, such as <jsp:setProperty name="foo" property="bar" value="<%= new java.util.Date() %>" /> When you use a request-time attribute value, the JSP container does not attempt to do any type conversion. In other words, the type of the expression must match the type of the corresponding bean property. In JSP 1.2, it’s possible to associate a so called “JavaBeans property editor” with the bean to convert string values to complex types like Date. I describe this approach in the second edition of the book. The bean conversion rules apply to attribute values in custom actions: literal String values are converted to the type of the corresponding property in the tag handler class if it’s one of the types listed above, and for other types you can use a request-time attribute value, or in JSP 1.2, create a property editor that knows how to convert strings to complex data types. |
InstantOnline Basic at JavaOne 2000
Gefion software’s president, Hans Bergsten, presented InstantOnline Basic for JSP at JavaOne 2000.
InstantOnline Basic for JSP Technology Preview 2 is Available
The InstantOnline Basic for JSP Technology Preview 2 is now available, giving you a peek at the next generation of our popular web application development tool. This preview version supports access to more data as variables, such as JavaBeans properties, array and Vector elements, cookies, etc.
LiteWebServer in Information Week
Our LiteWebServer is featured in Information Week’s What’s Hot section.
LiteWebServer 2.2.1 and WAICoolRunner 2.2.1 Released
LiteWebServer 2.2.1 and WAICoolRunner 2.2.1 are now available, with support for the latest server-side Java APIs: Servlet 2.2 and JSP 1.1 through the bundled Apache Tomcat JSP container.
Announcing InstantOnline Basic for JSP Technology Preview
Gefion software today announced the InstantOnline Basic for JSP Technology Preview, the first commercial web application development tool based on the new JavaServer Pages 1.1 specification.
Enabler 1.0 Available Free of Charge
A new product, the Enabler 1.0, is now available free of charge. The Enabler provides support for
LiteWebServer 2.2 and WAICoolRunner 2.2 Released
LiteWebServer 2.2 and WAICoolRunner 2.2 are now available, with support for the latest server-side Java APIs: Servlet 2.2 (PR1) and JSP 1.1 (PR2). The support license now covers the bundled Apache Tomcat JSP container as well.