• Post Reply Bookmark Topic Watch Topic
  • New Topic

Question ID :997046238320  RSS feed

 
Win Yu
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question ID :997046238320
Which of the following are correct JSP expressions?
why "<%=System.out.println(new Date())%>" is not correct answer.It will be "out.println(System.out.println(new Date()))".
Am I right?
 
ruijin yang
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Win,
For expression in JSP page,it need an String object.Here,
System.out.println(new Date()) itself is not a String.So it
produces error.If I am wrong,please correct me.
ruijin yang
 
Win Yu
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by ruijin yang:
Hello Win,
For expression in JSP page,it need an String object.Here,
System.out.println(new Date()) itself is not a String.So it
produces error.If I am wrong,please correct me.
ruijin yang

I think it will call "(new Date()).toSting()" method implicitly. Maybe the problem is out.println(Nov.23th 2:0pm) if "(new Date()).toSting()" =Nov.23th 2:0pm. Just guess.
 
Tim Duncan
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Win Yu:
I think it will call "(new Date()).toSting()" method implicitly.

I think you misunderstood. The problem is that the return value from the System.out call is not a String (it outputs a string on System.out, but that's not the same thing).
 
Win Yu
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Tim Duncan:
I think you misunderstood. The problem is that the return value from the System.out call is not a String (it outputs a string on System.out, but that's not the same thing).

OK I tried it. I got error:" Incompatible type for method. Can't convert void to java.lang.Object." The best way to understand is to try it. Thanks Duncan.

[This message has been edited by Win Yu (edited November 21, 2001).]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!