By: Abinaya Emailed: 1785 times Printed: 2614 times
MyBean bean = new MyBean();
String name = bean.getName();
This scriptlet creates a new instance of a class called MyBean, gets its name property, assigns this to a string variable, and then outputs this string to the page. Now you might be looking at this and thinking, “I can achieve the same thing by using the JSP standard actions (<useBean> and <getProperty>).”
Although this is certainly true, it was previously extremely hard to write a function-rich JSP-based web application without using a number of scriptlets within your pages. In fact, there are many problems associated with using Java code in the form of scriptlets in JSP pages.
The first and most obvious of these is that it’s very common for non-Java programmers to create the user interface for a system. This is because graphic designers are generally better than Java programmers at creating functional user interfaces. The second problem caused by the use of scriptlets is that of maintainability. Embedding large amounts of code into the user interface of a system makes the interface much harder to change and understand.
In fact, both ECMAScript and the XPath EL inspired the JSP EL. The EL specification states, “. . . the experts involved were very reluctant to design yet another expression language and tried to use each of these languages, but they fell short in different areas.”
If you’ve been following the progress of JSP, and the JSP Standard Tag Library (JSTL), you’re probably aware that the first expression language was released as part of the JSTL. The EL was then incorporated into the JSP 2.0 specification with JSTL 1.1. At around the same time, the JavaServer Faces (JSF) expert group was developing an expression language for JSF. Because of JSF requirements, the JSF expression language had some differences from the JSP expression language. JSP 2.1 unifies the two versions so that there is a single expression language used for JSP, JSTL, and JSF.
View Tutorial By: tony at 2009-03-04 17:03:03
Most Viewed Articles (in JSP )
Most Emailed Articles (in JSP)