Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

need some explanation

 
sand mehta
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
01.public class SessionAttr implements HttpSessionBindingListener {
public SessionAttr() {
System.err.println("Thanks for creating me");
}
public void attributeAdded(HttpSessionBindingEvent e) {
System.err.println("I have been added");
}
public void attributeRemoved(HttpSessionBindingEvent e) {
}
public void attributeUpdated(HttpSessionBindingEvent e) {
System.err.println("I have been updated");
}
}
WHat is printed to the stderr of the servlet container as a result of an instance of
SessionAttr being set in a session?
02.public class BListen implements HttpSessionBindingListener {
public void valueBound(HttpSessionBindingEvent e) {
System.err.println("session attr bound");
}
public void valueUnbound(HttpSessionBindingEvent e) {
}
}

assuming the web application deployment descriptor contains the appropriate elements for
defining class BListen as a listener. what is the result?
03.which two require declaring multiple servlet definitions for the same servlet class in a
deployment descriptor?
1.implementing servlet chaining
2.giving each servlet definition a different name
3.allowing the servlet class to handle requests from different urls
4allowing each definition to have different initialization parameters
04.what are the two HttpServletResponse methods can cause an HTTP error to be returned in
the servlet's response?
05.WHich will provide the ability to write the servlet log?
06.1. public class MisterBean {
private String firstName;
private int age;
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getFirstName() {
return firstName;
}
public void SetAge(int age) {
this.age = age;
}
public int getAge() {
return age;
}
}

Given index. jsp;

<html><body>
<jsp:useBean id="myBean" class="MisterBean" />
<jsp:setProperty name="myBean" property="firstName" />
<jsp:setProperty name="myBean" property="age" />
<%= myBean.getFirstName() %>, <%= myBean.getAge() %>
</body></html>
For the given URL http://localhost/index.jsp?fName=Fred&age=50
which change or (nochange) will cause "Fred, 50" to be included in the generated HTML?
 
chi Lin
Ranch Hand
Posts: 348
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my 0.02
01. will not compile, as attributeRemoved() is not defined
01.public class SessionAttr implements HttpSessionBindingListener {
public SessionAttr() {
System.err.println("Thanks for creating me");
}
public void attributeAdded(HttpSessionBindingEvent e) {
System.err.println("I have been added");
}
public void attributeRemoved(HttpSessionBindingEvent e) {
}
public void attributeUpdated(HttpSessionBindingEvent e) {
System.err.println("I have been updated");
}
}
WHat is printed to the stderr of the servlet container as a result of an instance of
SessionAttr being set in a session?
03.which two require declaring multiple servlet definitions for the same servlet class in a deployment descriptor?
1.implementing servlet chaining
2.giving each servlet definition a different name
3.allowing the servlet class to handle requests from different urls
4allowing each definition to have different initialization parameters
03. I will say 2 & 4
05.WHich will provide the ability to write the servlet log?
5. ServeletContext & GenericServlet
06.1. public class MisterBean {
private String firstName;
private int age;
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getFirstName() {
return firstName;
}
public void SetAge(int age) {
this.age = age;
}
public int getAge() {
return age;
}
}

Given index. jsp;

<html><body>
<jsp:useBean id="myBean" class="MisterBean" />
<jsp:setProperty name="myBean" property="firstName" />
<jsp:setProperty name="myBean" property="age" />
<%= myBean.getFirstName() %>, <%= myBean.getAge() %>
</body></html>
For the given URL http://localhost/index.jsp?fName=Fred&age=50
which change or (nochange) will cause "Fred, 50" to be included in the generated HTML?
6. First of all, I think MisterBean class is missing a no-arg constructor, and the "fName" in url should change to "firstName"
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic