摘要: JSP的九大内置对象: page,application,session,request,response,out,exception,config,pageContext. JSP的四个作用域:application,session,request,page.

//附上jsp转换成servlet后的java代码

package org.apache.jsp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.util.*; public final class index_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {    int count = 0;
   
   int getCount(){
   int num = 100;
   return num = 100*count;
   
   }
   
    
  private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();   private static java.util.List _jspx_dependants;   private javax.el.ExpressionFactory _el_expressionfactory;
  private org.apache.AnnotationProcessor _jsp_annotationprocessor;   public Object getDependants() {
    return _jspx_dependants;
  }   public void _jspInit() {
    _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
    _jsp_annotationprocessor = (org.apache.AnnotationProcessor) getServletConfig().getServletContext().getAttribute(org.apache.AnnotationProcessor.class.getName());
  }   public void _jspDestroy() {
  }   public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {     PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;     try {
      response.setContentType("text/html;charset=ISO-8859-1");
      pageContext = _jspxFactory.getPageContext(this, request, response,
                  null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;       out.write('\r');
      out.write('\n'); String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";       out.write("\r\n");
      out.write("\r\n");
      out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\r\n");
      out.write("<html>\r\n");
      out.write("  <head>\r\n");
      out.write("    <base href=\"");
      out.print(basePath);
      out.write("\">\r\n");
      out.write("    \r\n");
      out.write("    <title>My JSP 'index.jsp' starting page</title>\r\n");
      out.write("\t<meta http-equiv=\"pragma\" content=\"no-cache\">\r\n");
      out.write("\t<meta http-equiv=\"cache-control\" content=\"no-cache\">\r\n");
      out.write("\t<meta http-equiv=\"expires\" content=\"0\">    \r\n");
      out.write("\t<meta http-equiv=\"keywords\" content=\"keyword1,keyword2,keyword3\">\r\n");
      out.write("\t<meta http-equiv=\"description\" content=\"This is my page\">\r\n");
      out.write("  </head>\r\n");
      out.write("  \r\n");
      out.write("  <body>\r\n");
      out.write("  ");       
  
   
      out.write("\r\n");
      out.write("   \r\n");
      out.write("   ");
      out.write("\r\n");
      out.write("  \r\n");
      out.write("  ");
      out.print(++count );
      out.write("\r\n");
      out.write("  ");
      out.print( getCount() );
      out.write("\r\n");
      out.write("  <form action=\"test.do\" method=\"post\">\r\n");
      out.write("  <select name =\"color\">\r\n");
      out.write("  <option>White</option>\r\n");
      out.write("  <option>Red</option>\r\n");
      out.write("  <option>Yellow</option>\r\n");
      out.write("  <option>Blue</option>\r\n");
      out.write("  </select>\r\n");
      out.write("  \r\n");
      out.write("  <input type=\"checkbox\" name=\"hobby\" value=\"football\">football<br>\r\n");
      out.write("  <input type=\"checkbox\" name=\"hobby\" value=\"football\">basketball<br>\r\n");
      out.write("  <input type=\"checkbox\" name=\"hobby\" value=\"football\">baseball<br>\r\n");
      out.write("  \r\n");
      out.write("  <input type=\"submit\">\r\n");
      out.write("  </form>\r\n");
      out.write("  </body>\r\n");
      out.write("</html>\r\n");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try { out.clearBuffer(); } catch (java.io.IOException e) {}
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}

application作用域就是服务器启动到关闭的整段时间,在这个作用域内设置的信息可以被所有应用程序使用。application作用域上的信息传递是通过ServletContext实现的.

session作用域比较容易理解,同一浏览器对服务器进行多次访问,在这多次访问之间传递信息,就是session作用域的体现,

一个HTTP请求的处理可能需要多个Servlet合作,而这几个Servlet之间可以通过某种方式传递信息,但这个信息在请求结束后就无效了。Servlet之间的信息共享是通过HttpServletRequest接口的两个方法来实现的。

page对象的作用范围仅限于用户请求的当前页面,对于page对象的引用将在响应返回给客户端之后被释放,或者在请求被转发到其他地方后被释放。对page对象的引用通常存储在pageContext对象中。

转载:jsp九大内置对象和四大作用域的更多相关文章

  1. JSP九大内置对象和四大作用域和Servlet的三大作用域对象

    一.JSP九大内置对象:内置对象(又叫隐含对象,有9个内置对象):不需要预先声明就可以在脚本代码和表达式中随意使用 内置对象特点: 由JSP规范提供,不用编写者实例化. 通过Web容器实现和管理 所有 ...

  2. jsp九大内置对象和四大作用域

    看到网上一些Jsp内置对象介绍的都不是很全,今天我把各位大神的整理了一下. JSP九大对象:内置对象(又叫隐含对象,有9个内置对象):不需要预先声明就可以在脚本代码和表达式中随意使用. 一.reque ...

  3. JavaWeb中jsp九大内置对象 和四大作用域

    九大内置对象为 page request response session exception config application out pageContext no 内置对象  类型 1 pag ...

  4. servlet的三大作用域对象和jsp的九大内置对象及其四大作用域对象

    servlet的三大作用域对象: request(HttpServletRequest) session(HttpSession): application(ServletContext):tomca ...

  5. Jsp (Java Server Pages)相关知识九大内置对象和四大作用域

    一.初识JSP Jsp页面的组成:静态内容.指令.表达式.小脚本.声明.标准动作.注释等元素构成 Url:统一资源定位符 Url组成:协议.主机名(包括端口号).路径 1.注释的方式: 1.HTML注 ...

  6. Jsp语法九大内置对象和四大作用域

    一.JSP 原理:JSP其实就是一个servlet. Servlet负责业务逻辑处理,JSP只负责显示.开发中,JSP中不能有一行JAVA代码 二.JSP语法 1. JSP模板元素:JSP中HTML标 ...

  7. jsp的九大内置对象和四大作用域(转)

    定义:可以不加声明就在JSP页面脚本(Java程序片和Java表达式)中使用的成员变量 JSP共有以下9种基本内置组件(可与ASP的6种内部组件相对应): 1.request对象(作用域)  客户端的 ...

  8. jsp的九大内置对象和四大作用域

    定义:可以不加声明就在JSP页面脚本(Java程序片和Java表达式)中使用的成员变量? JSP共有以下9种基本内置组件(可与ASP的6种内部组件相对应):? 1.request对象(作用域)? 客户 ...

  9. AJPFX详解jsp的九大内置对象和四大作用域

    定义:可以不加声明就在JSP页面脚本(Java程序片和Java表达式)中使用的成员变量 JSP共有以下9种基本内置组件(可与ASP的6种内部组件相对应): 1.request对象(作用域) 客户端的请 ...

随机推荐

  1. DDD 应对具体业务场景,Domain Model 重新设计

    DDD 应对具体业务场景,Domain Model 重新设计 写在前面 上联:no zuo no die why you try 下联:no try no high give me five 横批: ...

  2. ASP.NET MVC Model绑定

    ASP.NET MVC Model绑定(一) 前言 ModelMetadata系列的结束了,从本篇开始就进入Model绑定部分了,这个系列阅读过后你会对Model绑定有个比较清楚的了解, 本篇对于Mo ...

  3. Jumony快速抓取网页

    Jumony快速抓取网页 --- Jumony使用笔记--icode   作者:郝喜路   个人主页:http://www.cnicode.com      博客地址:http://haoxilu.c ...

  4. 数据结构队列的java实现,包括线性和链式两种方式

    实现的思路为: 采用泛型的方式,首先定义了一个Queue的接口,然后通过实现该接口实现了线性和链式的两种形式的队列: 接口代码如下: package com.peter.java.dsa.interf ...

  5. IOS学习之路十七(通过delegate进行页面传值)

    加入有A B两个页面,要实现从A跳到B的时候把值传过去,现在用delegate协议来实现 在A中定义一个协议,定义一个实现该协议的属性变量 在B中定义一个值(要获得的值类型)和set方法. 要传值B ...

  6. UIKit类结构图

  7. ASP.NET Web API的核心对象:HttpController

    ASP.NET Web API的核心对象:HttpController 对于ASP.NET Web API来说,所谓的Web API定义在继承自ApiController的类中,可能ApiContro ...

  8. 需要我们了解的SQL Server阻塞原因与解决方法

    需要我们了解的SQL Server阻塞原因与解决方法 上篇说SQL Server应用模式之OLTP系统性能分析.五种角度分析sql性能问题.本章依然是SQL性能 五种角度其一“阻塞与死锁” 这里通过连 ...

  9. 基于存储过程的MVC开源分页控件

    基于存储过程的MVC开源分页控件--LYB.NET.SPPager 摘要 现在基于ASP.NET MVC的分页控件我想大家都不陌生了,百度一下一大箩筐.其中有不少精品,陕北吴旗娃杨涛大哥做的分页控件M ...

  10. 快速构建C++项目工具Scons,结合Editplus搭建开发环境

    Windows下C++开发工具用的最多的非VS莫属了(当然也有很多比如eclipse,Qt等等),便捷的项目构建向导,再加上强大的VC助手,使得开发和调试得心应手.并不是说vc就没有缺点,相反缺点也不 ...