• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

JSP Expression

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is my Jsp source.

<html>
<body>
<%!
String text="Welcome to Expression language";
%>
Welcome to the jsp programming.
<br/>
<strong>If you see this page, it means jsp are also funtioning properly.</strong>
Text = ${text}
</body>
</html>

When I deploy this jsp on tomcat server. For some reason expression ${text} is not replaced with the text Instead I am just seeing ${text} as is was.

Expected output for the expression part is :
-----------------------------------
Text = Welcome to Expression language
-------------------------------------

Did I miss something here.

Thanks!!

Shiva
[ November 22, 2005: Message edited by: shiva rao ]
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Did I miss something here."

Yes, the correct forum. Moving to JSP...
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmmm, you might want to check the server versions you are on and what JSTL and EL they support. Without checking myself, I remember reading that only the very latest spec versions support using ${test} inside the html in this manner. Previous versions of the spec do not support this and you will need to use



Instead. Check up on the JSTL tags and how to use them.
[ November 22, 2005: Message edited by: Derek Clarkson ]
 
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What version of Tomcat? Is your web app declared as a Servlet 2.4 web app? (See JSP FAQ)

The fact that the EL expression is not being evaluated means that the EL is not enabled. You must be using a JSP 2.0 container (Tomcat 5) and the web app must be declared as 2.4.

But....

once the EL is enabled you will fnd that this does not do what you expect.

The variable text is a scripting variable, while the EL operates upon scoped variables.
[ November 22, 2005: Message edited by: Bear Bibeault ]
 
shiva rao
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot for the reply. Here are the server details:

I am using Tomcat 5.5 and it supports JSP 2.0.
Here are the common jars it is refering to .

commons-el.jar
jasper-compiler-jdt.jar
jasper-compiler.jar
jasper-runtime.jar
jsp-api.jar
naming-factory-dbcp.jar
naming-factory.jar
naming-resources.jar
servlet-api.jar

And can you guys tell me how do I know whether server enabled or disabled the EL. And also where can I do that.

Thanks.
Shiva
 
Bear Bibeault
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is an entry in the JSP FAQ.
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As posted above, make sure the top of your DD is defined as using 2.4 as below
-------------------------------------------------
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
 
What I don't understand is how they changed the earth's orbit to fit the metric calendar. Tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic