protectedservlet.java
来自「Begining JSP Web Development外文书籍源代码」· Java 代码 · 共 26 行
JAVA
26 行
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 + =
减小字号Ctrl + -
显示快捷键?