Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!

Tresa P Anthony

Greenhorn
+ Follow
since Aug 14, 2006
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Tresa P Anthony

Hi,

Am surprised at the lukewarm response.

Anyways, the quoted text (including the examples) in my original post is from the JSP 2.0 spec.
Please explain how the container figures out the correct resource to include.

Thanks!
Hi,

The JSP 2.0 spec (Section - JSP.5.4) says


The page attribute of both the jsp:include and the jsp:forward actions are interpreted relative to the current JSP page, while the file attribute in an include
directive is interpreted relative to the current JSP file.



An example is also given:


Consider the following four situations built using four JSP files: A.jsp, C.jsp, dir/B.jsp and dir/C.jsp:
• A.jsp says <jsp:include page=”dir/B.jsp”/> and dir/B.jsp says <%@ include file=”C.jsp” %>. In this case the relative specification C.jsp resolves to dir/C.jsp.
• A.jsp says <%@ include file=”dir/B.jsp”%> and dir/B.jsp says <jsp:include page=”C.jsp”/>. In this case the relative specification C.jsp resolves to C.jsp.



I am confused how the container figures out which C.jsp to include in these cases. Basically, whats the difference between

current JSP page and current JSP file

? Can someone please clarify?

Thanks!!

Hi,

I am confused about how the toString()works.




Sec 3.10.5 of the JLS says:
Strings computed by constant expressions (�15.28) are computed at compile time and then treated as if they were literals.
Strings computed at run time are newly created and therefore distinct.



In the above code, isn't i.toString() evaluated at run time? But the output says both strings are Equal. Why is this so? Please explain.

Thanks
Tresa
15 years ago


Originally posted by Vlado Zajac

The error on first line is caused by trying to assign int to byte



As Mr.Zajac mentioned in an earlier post, the result of (Byte.MAX_VALUE +1) is of type int.
15 years ago
Hi all,

Thanks a lot for the explanations.

Tresa.
15 years ago
Hi,



This prints 15. Please explain how (using parenthesis if possible)

Thanks
Tresa
15 years ago
For the statement
byte b = 126 + 1;
the actual assignment of result to the variable 'b' happens at compile-time or is it at runtime?

Thanks
Tresa
15 years ago
So if the compiler does not perform any computations, how does it distinguish between the following assignments as legal/illegal?

1) byte b = 126 + 1; //legal
2) byte b = 126 + 6; //not legal without explicit casting to byte

Thanks
Tresa
15 years ago
Hi,

Thanks for the prompt reply.
Could you please confirm/clarify the following?

You cannot assign an int which is not a compile-time constant in the range of byte into a byte without an explicit cast.

In the second line, it only matters that the type of the expression is int.

The compiler does not carry out any calculations. It is only checking type in this case.



So in line 1, compiler computes the value (which is int) and complains as the value is outside the range of byte.
In line 2, compiler does not do any computation as we are trying to put an int value back into an int variable.

Please correct me if i got this wrong.

Thanks,
Tresa
15 years ago
Hi,

Could you please explain the following?


On compilation, i get a compile time error only at line 1 but not at line 2 as i had expected. Please explain why compiler okays line 2.
I am using jdk 1.4.
Thanks
[ August 15, 2006: Message edited by: Tresa P Anthony ]
15 years ago