import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class GetProtocolExample extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // Get the protocol name and version String protocol = request.getProtocol(); // Set the response content type response.setContentType("text/html"); // Write the protocol name and version in the response PrintWriter out = response.getWriter(); out.println(""); out.println("Description of Example: In this code example, we are creating a servlet that overrides the doGet() method. In the method, we are calling the HttpServletRequest getProtocol() method to get the name and version of the protocol used for the incoming request. Then, we are setting the response content type to "text/html". Finally, we are writing the protocol name and version in the response body. Package Library: The package library used in the above code example is javax.servlet.http. This package provides a set of interfaces and classes for the HTTP protocol. It is a part of the Java Servlet API.The protocol used is: " + protocol + "
"); out.println(""); } }