Moving to EL

  • Follow


I have the following in Tomcat 6.1.20 working in my JSP and now want
to eliminate the Scriptlet and use EL:
jsp:useBean id="dataBean" class="beanPackage.DataBean"
scope="request" />

<%= dataBean.getMessage("cityField") %>
------

My attempt didnt work because it doesnt like my EL part:
jsp:useBean id="dataBean" class="beanPackage.DataBean"
scope="request" />

${dataBean.getMessage("cityField")}
-----

Please advise how I can get this to work using EL instead of Scriptlet.
0
Reply teser3 (98) 10/20/2009 12:08:11 AM

teser3@hotmail.com wrote:
> I have the following in Tomcat 6.1.20 working in my JSP and now want
> to eliminate the Scriptlet and use EL:
> jsp:useBean id="dataBean" class="beanPackage.DataBean"
> scope="request" />
> 
> <%= dataBean.getMessage("cityField") %>
> ------
> 
> My attempt didnt work because it doesnt like my EL part:
> jsp:useBean id="dataBean" class="beanPackage.DataBean"
> scope="request" />
> 
> ${dataBean.getMessage("cityField")}
> -----
> 
> Please advise how I can get this to work using EL instead of Scriptlet.

jsp:useBean and EL serve different purposes.  You probably don't need the 
jsp:useBean.

'dataBean' can be placed by controller code (the "C" of "MVC") somewhere in 
the context of the JSP page, e.g., page scope, request scope, session scope. 
If that happens, then all you need is the EL:

   ${dataBean.message ["cityField"]}
or
   ${dataBean.message.cityField}

assuming that attribute 'message' is a 'Map' or attribute of a type of which .

Something you might have seen fit to mention.

Package names by usual convention (others exist) are spelled in all lower case.

The name 'DataBean' emphasizes the implementation ("It's a bean!") over the 
domain semantics ("What sort of data does it hold?").  This is perfectly fine 
if done on purpose, e.g., you mean to emphasize implementation for a Usenet 
code sample.

If you need more detailed information after reading
<http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html>
<http://java.sun.com/products/jsp/reference/techart/unifiedEL.html>
oh, heck,
<http://www.google.com/search?q=Java+EE+Unified+Expression+Language+EL>
you should construct and post an SSCCE.

-- 
Lew
0
Reply noone7 (3512) 10/20/2009 1:53:47 AM


1 Replies
24 Views

(page loaded in 0.04 seconds)


Reply: