JavaWeb学习总结8.13

《Servlet学习》

JavaWeb学习总结8.13_第1张图片
已经学习了前三种接口。
也写了一个便于巩固的小网页

index.jsp

<%--
  Created by IntelliJ IDEA.
  User: ZLB
  Date: 2019/8/13
  Time: 19:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>


  
  WebText
  



这是一个DW制作的前端网页显示~

 

 

web.xml



    
        a
        Servlet
    

    
        a
        /Servlet
    

    
    baidu
    www.baidu.com
    

    
        qqemil
        [email protected]
    

Servlet.java

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class Servlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("doGer~");

//        PrintWriter outt = resp.getWriter();
//        outt.print("

当前Web应用的所有初始化参数为:baidu qqemil"); // outt.print("baidu 参数值为 "+super.getServletContext().getInitParameter("baidu")); // outt.print("qqemil 参数值为 "+super.getServletContext().getInitParameter("qqemil")); } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { System.out.println("doPost~"); } @Override public void init() throws ServletException { System.out.println("出生了~"); } @Override public void destroy() { System.out.println("死掉了~"); } }

JavaWeb学习总结8.13_第2张图片
JavaWeb学习总结8.13_第3张图片

你可能感兴趣的:(学习总结)