• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

need some explanation

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 348
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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"
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic