public
String getScheme()
Returns
a String containing the name of the scheme(like ftp, http, https
etc.,) used to make this request.
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 = {"/GetScheme"}) public class GetScheme extends HttpServlet { @Override public void doGet(HttpServletRequest req, HttpServletResponse res)throws ServletException,IOException{ try(PrintWriter out = res.getWriter()){ String scheme = req.getScheme(); out.println("<html><head><title>Scheme Used</title><body><h1>"); out.println("Scheme used is : " + scheme); out.println("</h1></body></html>"); } } }
No comments:
Post a Comment