aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Complile time OR Request time error 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 "Complile time OR Request time error" Watch "Complile time OR Request time error" New topic
Author

Complile time OR Request time error

Poonam Agarwal
Ranch Hand

Joined: May 12, 2008
Posts: 323
Consider the following JSP codeEnthuware Mock)

<mylib:MyIterTag>
<%="Hello World"%>
</mylib:MyIterTag>

If the tag handler class for MyIterTag implements IterationTag and returns IterationTag.EVAL_BODY_BUFFERED from doStartTag(), what will be output in the response?

1. Hello World
2. <%="Hello World"%>
3. The tag handler will not compile.
4. The tag handler will compile but throw an exception at request time.
5. No compile-time or run-time erros and nothing will be printed in the output.

Correct answer is 3. I don't think so, becouse compiler checks weather it returns an int value or not. It is valid or not it will check at the request time.

Please correct me If i am getting it wrong.

Thanks

Thanks <br />Poonam Agarwal SCWCD 86%
Chithra Salam
Greenhorn

Joined: Mar 21, 2006
Posts: 19
MyIterTag implements IterationTag not BodyTag. So I think as EVAL_BODY_BUFFERED is not a field in IterationTag and so taghandler will not compile.

Thanks,
Chithra Salam.
[SCWCD -in progress,SCJP 1.4-85%]
Poonam Agarwal
Ranch Hand

Joined: May 12, 2008
Posts: 323
CHITHRA SALAM wrote:MyIterTag implements IterationTag not BodyTag. So I think as EVAL_BODY_BUFFERED is not a field in IterationTag and so taghandler will not compile.

Thanks,
Chithra Salam.
[SCWCD -in progress,SCJP 1.4-85%]


again, I don't think so, becouse compiler checks weather it returns an int value or not. It is valid or not it will check at the request time. check it by creating a sample .
Kamal Tripathi
Ranch Hand

Joined: Oct 02, 2008
Posts: 86
Poonam Agarwal wrote:

again, I don't think so, becouse compiler checks weather it returns an int value or not. It is valid or not it will check at the request time. check it by creating a sample .


Chithra is correct here. You are missing the point. What she meant is that EVAL_BODY_BUFFERED has been declared as a field in BodyTag interface and not in IterationTag.

So @ compile time it will fail.

What you say is true that compiler checks whether it returns int value or not but how would it return if it is not declared in the iterface!!!

See JSP 2.0 docs for each interface


http://tomcat.apache.org/tomcat-5.5-doc/jspapi/javax/servlet/jsp/tagext/IterationTag.html

http://tomcat.apache.org/tomcat-5.5-doc/jspapi/javax/servlet/jsp/tagext/BodyTag.html


Compiler takes the value of static fields and replaces them by their values at compilation so in class file you must be seeing an int value but for that it must find the field something like

public static final int EVAL_BODY_BUFFERED = ... ;

which it won't in this case.


Kamal Tripathi
SCJP 1.4 90%, SCWCD5 94%, Next SCDJWS--> In Naescent stage. Researching abt exam and material itself.
 
Don't get me started about those stupid light bulbs.
 
subject: Complile time OR Request time error