public
String getProtocol()
Returns
String containing the protocol name and version number.
import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet(urlPatterns = {"/GetProtocol"}) public class GetProtocol extends HttpServlet { @Override public void doGet(HttpServletRequest req, HttpServletResponse res)throws ServletException,IOException{ try(PrintWriter out = res.getWriter()){ String protocol = req.getProtocol(); out.println("<html><head><title>Protocol Used</title><body><h1>"); out.println("Protocol used is : " + protocol); out.println("</h1></body></html>"); } } }
No comments:
Post a Comment