Forums Register Login

question from jweb+

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
Log methods are provided in GenericServlet and ServletContext.
So 1 and 4 are correct
+Pie Number of slices to send: Send
Yes,& that's precisely why 2 is incorrect.
I'm full of tinier men! And a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 509 times.
Similar Threads
Mock Exam Question
Doubt in assertion
JWeb Plus Question ID: 996171458475
Marcus
Overloaded methods
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 15:15:26.