aspose file tools*
The moose likes JSP and the fly likes JSP Expression Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP Expression" Watch "JSP Expression" New topic
Author

JSP Expression

shiva rao
Ranch Hand

Joined: May 26, 2005
Posts: 31
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 ]
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
"Did I miss something here."

Yes, the correct forum. Moving to JSP...


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Derek Clarkson
Greenhorn

Joined: Mar 04, 2004
Posts: 25
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 ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

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 ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
shiva rao
Ranch Hand

Joined: May 26, 2005
Posts: 31
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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

There is an entry in the JSP FAQ.
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1506
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">


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: JSP Expression
 
Similar Threads
Error pages
EL is not working
Scripting Invalid
Problem Using Expresssion Language code in Tomcat
EL doubt