Meaningless Drivel is fun!*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes EL expression not returning value what i want Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "EL expression not returning value what i want" Watch "EL expression not returning value what i want" New topic
Author

EL expression not returning value what i want

Aman Lucky Singh
Greenhorn

Joined: Mar 25, 2014
Posts: 5
Actually I want to make my own tag for <c:forToken>


the code below is tag handler class

but the output is
${name}
${name}
${name}
${name}
thanks.
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1717
    
  25

Welcome to CodeRanch!

How does the structure of your web-app look like? Where is the .tld file located?

When you debug your code does it hit the setters of your Tag handler class?
Aman Lucky Singh
Greenhorn

Joined: Mar 25, 2014
Posts: 5
here is my c1.tld file which is located outside the WEB-INF folder along with .java file


<short-name>c</short-name>
<tag>
<name>forTokens</name>
<tag-class>my6.ForToken</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>items</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>delims</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>var</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>

</taglib>

I just want to print name written in items by using EL expression by my own tagHandler class

but if i am using <%= pageContext.getAttribute("name") %> in place of ${name} it print out correct output

thanks for your reply Frits sir

but give me reason why it is printing ${name} in place of name of items
Aman Lucky Singh
Greenhorn

Joined: Mar 25, 2014
Posts: 5
what i know about EL expression that when evaluating the expression ${name}, the container will look for name in the page, request, session, and application scopes and will return its value

when i have tried to write <%@ page isELIgnored ="false" %> in jsp file it return output what i want but why it is ignoring EL expresion .Is default value of EL is true

it will be greatefull to you to give me some knowledge on it
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61661
    
  67

See the ServletFAQ and JspFAQ -- if the EL is not being evaluated, you're web.xml is likely misconfigured.

You should not have to use the directive.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Aman Lucky Singh
Greenhorn

Joined: Mar 25, 2014
Posts: 5
thanks

I have change the web.xml now it is working

my web.xml is

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>

Actually i had copy this from JSTL but why it is not accepting EL expression is there any reason
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61661
    
  67

See the FAQ pages -- you need to declare the web.xml as moderne version of servlets. 2.3 is too old.
Aman Lucky Singh
Greenhorn

Joined: Mar 25, 2014
Posts: 5
I got it

thanks for your response
 
Don't get me started about those stupid light bulbs.
 
subject: EL expression not returning value what i want