Question ID :999982887730
Consider the following code:
public void LoggingServlet extends HttpServlet
{
public void doPost(HttpServletRequest req, HttpServletResponse res)
{
String theMessage = "Log test";
//1
}
}
Which of the following LOCs when inserted at //1 will put "Log test" in the log file?
1.log(theMessage);
2.req.log(theMessage);
3.res.log(theMessage);
4.this.getServletContext().log(theMessage);
5.this.servletConfig().log(theMessage);
The correct answers given are 1 and 4.
and as the explaination they have given the following line:
The log() methods are provided by ServletRequest and ServletContext interface.
As per servlet API doc ServletRequest doesn't have log method.
Also why 1 is correct ans?
thanks,
Trupti
Consider the following code:
public void LoggingServlet extends HttpServlet
{
public void doPost(HttpServletRequest req, HttpServletResponse res)
{
String theMessage = "Log test";
//1
}
}
Which of the following LOCs when inserted at //1 will put "Log test" in the log file?
1.log(theMessage);
2.req.log(theMessage);
3.res.log(theMessage);
4.this.getServletContext().log(theMessage);
5.this.servletConfig().log(theMessage);
The correct answers given are 1 and 4.
and as the explaination they have given the following line:
The log() methods are provided by ServletRequest and ServletContext interface.
As per servlet API doc ServletRequest doesn't have log method.
Also why 1 is correct ans?
thanks,
Trupti