• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

not getting the EL

 
Bhavna Jharbade
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bhavna Jharbade
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not getting the value of sent even if i make the body-content empty
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
For me the expected output is coming.Also,if tag content is empty,compilation fails.
Reg
Vasanth
 
Bhavna Jharbade
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Chandra Atla
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Add this directive to your jsp file.
<%@ page isELIgnored="false" %>
[ October 20, 2005: Message edited by: Raghu Shree ]
 
Raghu Shree
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic