Win a copy of Spring Boot in Practice this week in the Spring forum!

Sandya Bhaskara

Ranch Hand
+ Follow
since Aug 20, 2004
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 Sandya Bhaskara

hey..those interested in JFTP...take a look at www.myjavaworld.com..it is really cool
17 years ago
congrats kartik....i agree with u..the level of difficulty i almost the same as that of mock(in fact i found some questions harder than mock)..even i scored very less in mock(48/69) bcoz it didn't have a clue about num of correct answers...and today in the real exam i got 88%..
17 years ago
and i forgot to mention..this ranch is a wonderful place for java programmers..i'm a life long member here..its so cool.. and also the SCWCD links given here are useful i think..though i didn't get a chance to go thru them
17 years ago
hi..today i passed SCWCD1.4 with 88%...i have absolutely no experience in servlets/jsp and i prepared for 3 weeks...HFS was the only book i referred to..took the final HFS mock test yesterday night and got 68%....i found some mistakes(may be i was wrong )in the final mock and i 'll post my doubts in SCWCD forum soon...anyway i'm very happy...but the exam is definitely not easy...i felt the programmer certification is very much easier than this..i got some 7-8 questions on patterns..required lots of thinking...scored 100% in all sections except tags..got only 50%..some questions that appeared on exam were not covered by HFS..but to PASS the exam i think HFS is all u need...
17 years ago
<jsp:useBean id="person" type="foo.Employee">
<jsp:setProperty name="person" property="name" value"Fred"/>
</jsp:useBean>


servlet code:

foo.Person =new foo.Employee();
p.setName("Evan");
request.setAttribute("person",p);


the answer given for this "Be the Container" is -it wont work because container looks for bean in page scope while actual bean exists in request scope.



Ok..now my doubt...
lets make the scope as request instead of default page scope
<jsp:useBean id="person" type="foo.Employee" scope="request">

will this work??
i mean i'm not sure how container generates the code when only type is given..

foo.Employee person=null;
synchronized(request){
person=(???downcastedto???)pageContext.getAttribute("person",PageContext.REQUST_SCOPE)
....
}

person will be downcasted to foo.Employee or foo.Person??if it is foo.Person then u get an exception since u cant assign foo.Person object to foo.Employee reference..
i'm confused
is the order of elements in xml imortant?
i mean is this valid??
<context-param>
<param-value>....</param-value>
<param-name>...</param-name>
</context-param>


one more ques...
if u want to give more than one context param.how would u declare it?
<context-param>
<param-name>...</param-name>
<param-value>....</param-value>
</context-param>
<context-param>
<param-name>...</param-name>
<param-value>....</param-value>
</context-param>

or
<context-param>
<param-name>...</param-name>
<param-value>....</param-value>

<param-name>...</param-name>
<param-value>....</param-value>
</context-param>

what about listeners?
What gets printed when the following JSP code is invoked in a browser. Select the one correct answer.
<%= if(Math.random() < 0.5) %>
hello
<%= } else { %>
hi
<%= } %>


a.The browser will print either hello or hi based upon the return value of random.
b.The string hello will always get printed.
c.The string hi will always get printed.
d.The JSP file will not compile.

The answer was d...but i think it should give the following O/P...
if(Math.random()<5hello}else{hi}
am i wrong?
Fill in what would you put into a Tag File to declare hat the Tag must NOT have a body..

the answer given was
<%@tag body-content="tagdependent" %>

i thought it was body-content="empty"...was i wrong?
i'm confused...
page 132 HFS-use write() when you get ServletOutputStream from response and use print()/println() when u get a PrintWriter

but in page 293..when JSP becomes servlet...
the example shows..
out.write(....);
out.print(...);
(The container converts JSP to a servlet-here out is a JspWriter similar to the PrintWriter object we get from response)


From Java I/O i understand that u do have write() method in API for PrintWriter...but why cant we use it when we get a PrintWriter object for response ??why HFS states that we should use should use only println()for PrintWriter?
even i got the same doubt..but i think its the server that adds header info to the response and sends the http response to the client...HFS clearly states that it wont show the server unless required...may be we got confused because of that-container sending the HTTP response ....
question number 5...
I think option D is also correct..

Filters support an initialization mechanism that includes init() method that is guarenteed to be called before filter is used to handle requests...


why is not a correct (according to HFS its not right - but filters do have init() method to perform initialization)
Generally java resolves calls to methods dynamically at run time..(late binding)..but for methods that cant be overridden a call can be resolved at compile time(example-final ,static methods)..the compiler copies the bytecode for subroutine directly inline with compiled code of the calling methods thus eliminating costly overhead associated with the method call...
This is INLINE call..

but i'm not sure what a callback is....and i did not understand why destroy() is callback method and doFilter()is both inline and callback..??
why can't u override service() in HttpServletClass??HFS says never to override this method.....
but why not override this method so that the servlet will service any request from the client(irrespective of whether the request is get,post,put etc)....i have written code overriding the service method and it executed fine...