• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

standard action doubt

 
sukhavasi vasavi
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<%{%
<jsp:useBean id="buffer" class="java.lang.String.Buffer"/>
<%buffer.append("xyz");%>
<%}%>
buffer is:<%=buffer%>

what appears on the stream?
a)an error occurs at compilation time
b)an eror occurs at translation time
c)the string "buffer is xyz" appears in the response stream
d)the string "buffer is null " appears in the response stream

Given ans:a
Please explian why the compilation error occurs?
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

There is no class like java.lang.String.Buffer in java.lang package.

Thanks
 
Vidya Sethuraman
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please correct me if I'm wrong.

I observed that the scriptlet tag is not closed in the first line.
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you fix those two things though I think this code is highlighting a point from basic Java. The {} braces do nothing more than limit the scope of the buffer variable. The expression scriptlet is outside that block, so there should be a compilation error.

Crazy stuff. There won't be anything like this on the real exam.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic