JSP-内置对象、MVC-jsp演变历史

JSP-内置对象

  在jsp页面中不需要创建,直接使用的对象

  一共有9个:

    变量名 真实类型 作

      pageContext PageContext 当前页面共享数据,还可以获取其他八个内置对象

      request HttpServletRequest 一次请求访问的多个资源(转发)

      session HttpSession 一次会话的多个请求间

      application ServletContext 所有用户间共享数据

      response HttpServletResponse 响应对象

      page Object 当前页面(Servlet)的对象 this

      out JspWriter 输出对象,数据输出到页面上

      config ServletConfig Servlet的配置对象

      exception Throwable 异常对象

<%@ page contentType="text/html;charset=UTF-8" language="java"  %>
<%@include file="top.jsp"%>

<html>
<head>
    <title>Title</title>
</head>
<body>

    <!--
        <h1>hello</h1>
    -->
    <%--
        <%
            System.out.println("hi~~~~");
        %>
    --%>
<%--

    <input>
--%>

    <%

        pageContext.setAttribute("msg","hello");

    %>





    <%=pageContext.getAttribute("msg")%>



</body>
</html>

 

MVC-jsp演变历史

  1. jsp演变历史

    1. 早期只有servlet,只能使用response输出标签数据,非常麻烦

    2. 后来又jsp,简化了Servlet的开发,如果过度使用jsp,在jsp中即写大量的java代码,有写html表,造成难于维护,难于分工协作

    3. 再后来,java的web开发,借鉴mvc开发模式,使得程序的设计更加合理性

posted @ 2022-12-08 21:59  漁夫  阅读(27)  评论(0)    收藏  举报