📄 protectedservlet.java
字号:
package com.wrox.servlets;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.security.*;
public class ProtectedServlet extends HttpServlet
{
public void init(ServletConfig cfg) throws ServletException
{
super.init(cfg);
}
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws IOException, ServletException
{
res.setContentType("text/plain");
PrintWriter out = res.getWriter();
String authType = req.getAuthType();
out.println("You are authorized to view this page");
out.println("You were authenticated using: " + authType
+ " method of authentication");
Principal princ = req.getUserPrincipal();
out.println("The user is: " + princ.getName());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -