Forums Register Login

EL is not being recognized

+Pie Number of slices to send: Send
hi there,
I've written a very simple test for jsp that is failing:

the bean is a simple standard bean with one attribute: "name"

in the servlet:

HttpServletRequest request = getThreadLocalRequest();
HttpSession session = request.getSession();

TestBean tb = new TestBean();
tb.setName("Dee");
session.setAttribute("testBean", tb);


in the jsp file:

${testBean.name}



server is tomcat 5.5

the output result on the jsp page is:
${testBean.name}


so, EL is not being recognized;
is there a setting or a tag to inform tomcat how to properly generate the page?


the following does work, tho:

<%
java.util.Date date = new java.util.Date();
%>
Hello! The time is now <%= date %>


any assistance would be greatly appreciated

B
+Pie Number of slices to send: Send
Look at the top of your web.xml and see if it's listed as servlet version 2.4.
+Pie Number of slices to send: Send
Please fix your code using <code> </code> from above.. Thanks..

[ UD: Note that code tags use rectangle brackets, not angle brackets. ]
+Pie Number of slices to send: Send
I suspect you are not using JSP 2.0 . in jsp 2.0 EL is enabled by default and in previous version it is disabled by default.
I think this might help you.
+Pie Number of slices to send: Send
 

Gab Narwaria wrote:I suspect you are not using JSP 2.0 . in jsp 2.0 EL is enabled by default and in previous version it is disabled by default.


Not always. It depends upon how the deployment descriptor is declared -- which is why Ben asked about that above.
+Pie Number of slices to send: Send
thank you very much for your replies; much appreciated.
I've also tried to run the jsp examples that come with tomcat and I've the same result:
EL is not being recognized; it is tomcat 5.5 I'm using.
checking the web.xml is a good idea and it's indeed version 2.4.

I'm thinking all I can do is to re-install tomcat and hope somehow it works.

B
+Pie Number of slices to send: Send
If you are using Tomcat 5.5, and the deployment descriptor is correctly declared, there is no reason that the EL should not work.

Perhaps it's time to post your code?
+Pie Number of slices to send: Send
hi there,

thank you for all your suggestions:
it turns out that there were two problems:
at some point in the development of the app I add to the tomcat lib
directory a jar file - not sure which one exactly but likely a 'jasper' or 'servlet' - which caused
tomcat to turn off JSP;
second, different urls - ip address of the box vs 'localhost' - for the same localhost were being used for the app and for the
jsp url causing the tomcat to see different sessions and the JSP bean was being
stored in the bean.

a thought: there is a real need for some kind of central repository per technology that - given a situation - helps one to ask
questions. a simple faq might work in many cases.
in this case the questions would include:
- check the servlet version and web-xml,
- are there any jasper or servlet jars in the lib dir which may not need be there?
- check that the urls being used as exactly the same if beans are being stored in the session.

B
I RELEASE YOU! (for now .... ) Feel free to peruse this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1102 times.
Similar Threads
servlet , bean , jsp Communication
Extracting data from a bean
JSF navigation questions
JavaScript & JSP Please help
Getting null if i do not do an explicit new TestBean() in Action Class .....
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 03:25:37.