File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes not getting the EL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "not getting the EL" Watch "not getting the EL" New topic
Author

not getting the EL

Bhavna Jharbade
Ranch Hand

Joined: Sep 08, 2005
Posts: 69
Hi all
i have the following tag file n jsp page

Header.tag


Tagfile.jsp


Output i am getting

${sent} Today is Tuesday
Welcome!!!


i.e i am not getting the value of sent attribute.
Can anyone help me figure out why so?
Thanks in advance.


SCJP1.4 (86%)
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
Hi,

I think problem is because of ( assuming EL is turned on )

<%@ tag body-content="tagdependent" %>

If the body-content is tagdependent , the body will not processed.

Thanks


Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
Bhavna Jharbade
Ranch Hand

Joined: Sep 08, 2005
Posts: 69
I am not getting the value of sent even if i make the body-content empty
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
empty value means no body processed. pl try scriptless as JSP is not valid value in tag attribute.

OR remove the <%@ tag body-content="tagdependent" %> line as the scriptless is default value.

Thanks
[ October 18, 2005: Message edited by: Narendra Dhande ]
Vasanth Raja.K.
Ranch Hand

Joined: May 30, 2005
Posts: 35
Hi,
For me the expected output is coming.Also,if tag content is empty,compilation fails.
Reg
Vasanth


SCJP 1.4(85%)<br />SCWCD 1.4(79%)
Bhavna Jharbade
Ranch Hand

Joined: Sep 08, 2005
Posts: 69
hi Narendra
i think u r asking me to have the 2 files as shown below....
Header.tag


Tagfile.jsp


But still i am not getting the value of attribute sent in the output.Correct me if u meant something different.
Srinivasan Rengan
Ranch Hand

Joined: Nov 07, 2004
Posts: 122
Hi Bhavna,
I suppose you are using jsp1.2, wherein EL's are disabled by default.

Please check up your version. In JSP 2.0 it is enabled by default.

Srini
[ October 19, 2005: Message edited by: Srinivasan R ]

SCJP, SCWCD, SCBCD (EJB 2.x and EJB 3), OCA, SCDJWS
Chandra Atla
Ranch Hand

Joined: Jul 21, 2004
Posts: 91
Hi,

I have copied the Header.tag file to webappas/jsp-examples/WEB-INF/tags directory of Tomcat 5.0 and copied the TagFile.jsp to webapps/jsp-examples/ directory.
When I access it using http://127.0.0.1:8080/jsp-examples/TagFile.jsp, it's working fine.

When the files are under webapps/ROOT (under respective directories), it's not working. I guess it has something to do with the version attribute of web-app tag.

Thanks,
Chandra
[ October 19, 2005: Message edited by: Chandra Atla ]
Bhavna Jharbade
Ranch Hand

Joined: Sep 08, 2005
Posts: 69
Hi Narendra n Chandra
Narendra, mine is JSP 2.0.
Also as Chandra said the example is working fine from within jsp-example not from webapps/root

So anyone can plz suggest possible reason.
Radhika Jonnalagadda
Ranch Hand

Joined: Oct 13, 2004
Posts: 89
Hi Bhavna,

I think Tomcat5.0 needs some working directory under 'webapps' as opposed to 'root'.


When the files are under webapps/ROOT (under respective directories), it's not working.


correct me if I am wrong.

regards,
JR


best regards,<br />Radhika<br /> <br />Dare to Dream.Care to Achieve.<br />SCJP 1.4, SCWCD 1.4.
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
Hi,

Really I made some confusions about above example. I have tested the codes

Header.tag

<%@ attribute name="sent" required="true" rtexprvalue="true" %>
<%@ tag body-content="tagdependent" %>
${sent} // attribute value, Should always evaluated.
<jsp oBody/>



Tagfile.jsp

code:


<%@ taglib prefix="myTags" tagdir="/WEB-INF/tags"%>
<html><body>
<myTags:Header sent="Today is 18th">
Today is Tuesday
</myTags:Header>
<br>
Welcome!!!
</body>
</html>

It is displaying the value of sent as Today is 18th. There no problem of body-content="tagdependent" in the Header.tag file.

If the tag file contain body-content="tagdependent" in tag directive. It will affect to the processing of body of tag. (<jsp oBody/> that is if I put some code in the Tagfile.jsp
<myTags:Header sent="Today is 18th">
Today is Tuesday x = ${1+2+3}
</myTags:Header>

Then the EL in the body of the tag ${1+2+3} is not processed as not display 6.

But when I remove the line 2 from Header.tag it is displaying value 6 properly.

To test this example, I created seperate application. The Header.tag file is placed under app1/WEB-INF/tags directory and the Tagfile.jsp is placed under app1 directory.

Thanks
[ October 20, 2005: Message edited by: Narendra Dhande ]
Raghu Shree
Ranch Hand

Joined: Mar 18, 2005
Posts: 143
Hi
Add this directive to your jsp file.
<%@ page isELIgnored="false" %>
[ October 20, 2005: Message edited by: Raghu Shree ]

Raghu J<br />SCJP 1.4<br /> <br />The Wind and waters are always<br />on the side of the ablest navigators.<br /><a href="http://groups.yahoo.com/group/scjp_share" target="_blank" rel="nofollow">SCJP Group</a><br /><a href="http://groups.yahoo.com/group/JavaBeat_SCWCD" target="_blank" rel="nofollow">SCWCD Group</a>
Raghu Shree
Ranch Hand

Joined: Mar 18, 2005
Posts: 143
Hi Bhavna ,
I can reproduce your problem in my machine. I think the problem is in web.xml. Change your <web-app> tag like below

<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">


This tag will enable the EL expression in your jsp file. And also add the directive <%@ page isELIgnored="false" %> (optional) in your jsp file.

I have reproduced the same problem to change the web.xml <web-app> tag like below


<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">


This tag is used for to disable the el expression in our web application.
Hope this will helps you.

Reply with the result
 
Don't get me started about those stupid light bulbs.
 
subject: not getting the EL