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 <c:out> is not working properly Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "<c:out> is not working properly" Watch "<c:out> is not working properly" New topic
Author

<c:out> is not working properly

Anil Deshpande
Ranch Hand

Joined: Jan 13, 2008
Posts: 117
I am using Head First Servlets and JSP to prepare for SCWCD.

In the book there is code using<cut> tag which is not working. I have places the jstl.jar and standard.jsr file in WEB-INF/lib directory.

It is not displaying the currentTip

I will just reproduce the code here.

servlet code:


The tip.jsp code


The out put is:
Tip of the day is

It is not diaplying the currentTip? I don't understand what seems to be the problem. I have done everything axactly as told in the book. I am stuck at this an unable to move ahead. And this is stalled my prepaeration. Please help me solve this problem.

regards
Anil Deshpande


Anil Deshpande
SCJP 1.5, SCWCD 1.5
Dumitru Postoronca
Ranch Hand

Joined: May 06, 2008
Posts: 46
Try using pageContext instead of pageContent.
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


Did you specify taglib for what c is ?
Cezary Rzewuski
Greenhorn

Joined: Jan 05, 2009
Posts: 3
I don't understand where is pageContect object from? There is pageContext object but not pageContent - as far as I know.
Try just .
chandraiah chintakayalu
Ranch Hand

Joined: Aug 30, 2007
Posts: 32
Hi,
Your are using the Expression Lang, in order to use E.L in your page you should enable it by default it is disabled.
<%@ isELIgnored="false" %>
put this code hope so it works.


SCJP-5 86%,SCWCD-soon
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14685
    
  16

Your are using the Expression Lang, in order to use E.L in your page you should enable it by default it is disabled.

No, it is enabled by default, at least since JSP2.0. Don't use the isELIgnored attribute.
Also, it is an attribute of the page directive. Your notation would not work.


[My Blog]
All roads lead to JavaRanch
Anil Deshpande
Ranch Hand

Joined: Jan 13, 2008
Posts: 117
In the book it is printed as pageContent. It is not working. i don't know whether it is printing mistake or something else. Just to cross check I changed it to pageContext.currentTip, It gave an exception. The exact details of the exception are as follows.



Then I even chaned it to cust currentTip, It doesn't make any difference. Even though exception is not thrown, nut stull it doesn't sisplay anything. What seems to be problem?


Did you specify taglib for what c is ?


What does that mean, and how to do it. I have placed the JSTL jar files in the WEB-INF/lib directory.If that's what you mean
Harshana Dias
Ranch Hand

Joined: Jun 11, 2007
Posts: 325
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"; prefix="c" %>

Do you have it in your JSP?
Mateus Lucio
Ranch Hand

Joined: Jul 27, 2006
Posts: 57
Hi there, like Cezary said ... try this
Cezary Rzewuski wrote:I don't understand where is pageContect object from? There is pageContext object but not pageContent - as far as I know.
Try just .


EL will check all available scopes searching for an attribute bound with the name "currentTip"

you can also do it like this


I wonder how you got the exception, since EL is null friendly .... very weird!


Studying ...
Anil Deshpande
Ranch Hand

Joined: Jan 13, 2008
Posts: 117
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"; prefix="c" %>

(In the Head first book nothing about that is mentioned, that's why I didn't know it)

Well I didn't know that. I did include that in the jsp. It seems to to be moving somewhere ahead. Thre seems to be some minute problem.

Now its giving another exception in jsp.



What shall I do?



I wonder how you got the exception, since EL is null friendly .... very weird!
That's what I too am unable to understand
regards

Anil Deshpande
vani venkat
Ranch Hand

Joined: Nov 21, 2006
Posts: 142
hi
is the correct syntax for describing custom libraries in jsp. there was an extra semicolon in above post.


SCJP 1.4, SCWCD 1.5
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14685
    
  16

In any case, this definition is old. You should be using this one :


Check this page.
Anil Deshpande
Ranch Hand

Joined: Jan 13, 2008
Posts: 117
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>



This tag is working perfectly fine. But I changed pageContent.currentTip to just currentTip, or requestScope.currentTip. I personally feel there is no EL having pageContent. and anyhow pageContext is throwing the exception.

The code is working fine now. Thanks a lot guys. I really appreciate all the replyes.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14685
    
  16

1. There is no pageContent implicit object in EL
2. There is a pageContext implicit object in EL, whose type is javax.servlet.jsp.PageContext. This class has no method called "getCurrentTip", which causes the exception.
3. The "currentTip" attribute is set in the request, so as Mateus said, you can either use the requestScope implict object to get it (${requestScope.currentTip}), or let the container look for it by using ${currentTip} instead.

That should be added to the errata of the book, if it's not already there.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: <c:out> is not working properly
 
Similar Threads
unable to understnad the syntax of JSTL
Browser Path Not Refreshing
usebean id problem
HFSJ 2nd edition page 383 - div class
chat servlet