This section illustrates you how to use log in Servlet Context.
We are providing you an example. In the given example, an object of Servlet Context is defined. The method context.log() writes the specified message to a servlet log file. The name and type of the servlet log file is specific to the servlet container.
Here is the code of LogInServlet.java
import java.io.IOException;
|
In web.xml, do the following servlet-mapping
| <servlet> <servlet-name>LogInServlet</servlet-name> <servlet-class>LogInServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>LogInServlet</servlet-name> <url-pattern>/LogInServlet</url-pattern> </servlet-mapping> |
After deploying the tomcat, Following output will be displayed on the browser

The message provided through the servlet has been written in the log file

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Use Log in Servlet Context
Post your Comment