thilakk kumar

Greenhorn
+ Follow
since Feb 20, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by thilakk kumar

What will it print for the very first request to this page as well as the web application that contains this page?


<html><body>

<%

Integer count = (Integer) request.getSession(false).getAttribute("count");

if(count != null )

{

out.println(count);

}

else request.getSession(false).setAttribute("count", new Integer(1));

%>

Hello!

</body></html>

Select 1 correct option.
A.It will print Hello!
B.It will print Hello and will set the count attribute in the session.
C.It will throw a NullPointerException at request time.
D.It will not compile.


Answer is B. But i8 thought as the request.getSession(false) will always return the existing session this will raise a null pointer exception.can anyone clear my doubts
Thanks for all This helps me a lot
class abstract Person {
String getName()
void setName(String)
}

class Employee extends Person {
int getEmpId()
void setEmpId(int)
}


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

jsp:
<jsp:UseBean id="person" type="Employee" scope="request" >
<jsp:setProperty name="person" property="name" value="fred" />
</jsp:useBean>
Name is:<jsp:getProperty name="person" property="name" />


In Head first its given that the above code fails at request time .The person attribute is stored at request scope ,so the <jsp:useBean> tag wont work since it specifies only a type.The container knows that if you have only a type specified,there must be an existing attribute of that name and scope.

Iam not clear with the answer .acn nyone clear my doubt?
Can
Hi bryan Thanks in advance

You mentioned to rory that the chances of passing the SCWD5 exam with the current HFSJ is very good.What if i want to score a good marks.Should i need to buy the new version as i have the old version (1.4) with me
Hey Frends
I need to call a batch file from a program , and at the same time i need to call the batch file and the program shud stop execution.
Can we write our own constructor for a servlet