我有一个欢迎文件是 servlet 的网站。
<welcome-file-list>
<welcome-file>Main</welcome-file>
</welcome-file-list>
servlet 从数据库中收集数据并将其发送到 JSP。如何将所有请求从主 servlet 重定向到 https?任何的想法???谢谢
感谢 Eng.Fouad的提示...问题已解决
//Check if the requested scheme is http then redirect it to https
if(request.getScheme().equals("http"))
{
response.sendRedirect("https://www.mysite.com");
}
//If the request is not http but https then collect the data and send to jsp
else
{
//Collect the data from the database and send it to JSP
request.setAttribute("data",data);
RequestDispatcher rd = request.getRequestDispatcher("/main.jsp");
rd.forward(request, response);
}