Moving to EL

T

teser3

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")}
 
L

Lew

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")}

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,140
Latest member
SweetcalmCBDreview
Top