1、容器根据你所写的JSP生成一个类,

/*
* Generated by the Jasper component of Apache Tomcat
* Version: Apache Tomcat/7.0.77
* Generated at: 2017-06-11 15:47:28 UTC
* Note: The last modified time of this file was set to
* the last modified time of the source file after
* generation to assist with modification tracking.
*/
package org.apache.jsp; import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*; public final class HelloWorld_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent { private static final javax.servlet.jsp.JspFactory _jspxFactory =
javax.servlet.jsp.JspFactory.getDefaultFactory(); private static java.util.Map<java.lang.String,java.lang.Long> _jspx_dependants; private org.apache.jasper.runtime.TagHandlerPool _005fjspx_005ftagPool_005fs_005fproperty_0026_005fvalue_005fnobody; private volatile javax.el.ExpressionFactory _el_expressionfactory;
private volatile org.apache.tomcat.InstanceManager _jsp_instancemanager; public java.util.Map<java.lang.String,java.lang.Long> getDependants() {
return _jspx_dependants;
} public javax.el.ExpressionFactory _jsp_getExpressionFactory() {
if (_el_expressionfactory == null) {
synchronized (this) {
if (_el_expressionfactory == null) {
_el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
}
}
}
return _el_expressionfactory;
} public org.apache.tomcat.InstanceManager _jsp_getInstanceManager() {
if (_jsp_instancemanager == null) {
synchronized (this) {
if (_jsp_instancemanager == null) {
_jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(getServletConfig());
}
}
}
return _jsp_instancemanager;
} public void _jspInit() {
_005fjspx_005ftagPool_005fs_005fproperty_0026_005fvalue_005fnobody = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig());
} public void _jspDestroy() {
_005fjspx_005ftagPool_005fs_005fproperty_0026_005fvalue_005fnobody.release();
} public void _jspService(final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response)
throws java.io.IOException, javax.servlet.ServletException { final javax.servlet.jsp.PageContext pageContext;
javax.servlet.http.HttpSession session = null;
final javax.servlet.ServletContext application;
final javax.servlet.ServletConfig config;
javax.servlet.jsp.JspWriter out = null;
final java.lang.Object page = this;
javax.servlet.jsp.JspWriter _jspx_out = null;
javax.servlet.jsp.PageContext _jspx_page_context = null; try {
response.setContentType("text/html; charset=UTF-8");
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\n");
out.write("\r\n");
out.write("<html>\r\n");
out.write("<head>\r\n");
out.write("<title>Hello World</title>\r\n");
out.write("</head>\r\n");
out.write("<body>\r\n");
out.write(" Hello World, ");
if (_jspx_meth_s_005fproperty_005f0(_jspx_page_context))
return;
out.write("\r\n");
out.write("</body>\r\n");
out.write("</html>");
} catch (java.lang.Throwable t) {
if (!(t instanceof javax.servlet.jsp.SkipPageException)){
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
try {
if (response.isCommitted()) {
out.flush();
} else {
out.clearBuffer();
}
} catch (java.io.IOException e) {}
if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
else throw new ServletException(t);
}
} finally {
_jspxFactory.releasePageContext(_jspx_page_context);
}
}
private boolean _jspx_meth_s_005fproperty_005f0(javax.servlet.jsp.PageContext _jspx_page_context)
throws java.lang.Throwable {
javax.servlet.jsp.PageContext pageContext = _jspx_page_context;
javax.servlet.jsp.JspWriter out = _jspx_page_context.getOut();
// s:property
org.apache.struts2.views.jsp.PropertyTag _jspx_th_s_005fproperty_005f0 = (org.apache.struts2.views.jsp.PropertyTag) _005fjspx_005ftagPool_005fs_005fproperty_0026_005fvalue_005fnobody.get(org.apache.struts2.views.jsp.PropertyTag.class);
boolean _jspx_th_s_005fproperty_005f0_reused = false;
try {
_jspx_th_s_005fproperty_005f0.setPageContext(_jspx_page_context);
_jspx_th_s_005fproperty_005f0.setParent(null);
// /HelloWorld.jsp(8,16) name = value type = java.lang.String reqTime = false required = false fragment = false deferredValue = false expectedTypeName = null deferredMethod = false methodSignature = null
_jspx_th_s_005fproperty_005f0.setValue("name");
int _jspx_eval_s_005fproperty_005f0 = _jspx_th_s_005fproperty_005f0.doStartTag();
if (_jspx_th_s_005fproperty_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
return true;
}
_005fjspx_005ftagPool_005fs_005fproperty_0026_005fvalue_005fnobody.reuse(_jspx_th_s_005fproperty_005f0);
_jspx_th_s_005fproperty_005f0_reused = true;
} finally {
org.apache.jasper.runtime.JspRuntimeLibrary.releaseTag(_jspx_th_s_005fproperty_005f0, _jsp_getInstanceManager(), _jspx_th_s_005fproperty_005f0_reused);
}
return false;
}
}

2、需要知道的一些问题

对于问题1:JSP有一个内置对象叫config,它相当于servlet中的ServletConfig,在servlet中我们需要通过getServletConfig来获得它,然后再通过例如getInitParameter("name");获得参数,整个过程类似这样

而在JSP,由于它本身具有这样一个内置对象,因此只需要像下面这样就可以了

对于问题2:我猜想也是在web.xml中配置,因为JSP说到底不过是servlet的另外一种“书写方式”罢了。

事实证明这是正确的,

对于问题3:直接在<%!%>中进行覆盖就可以了

分享一段话

【Head First Servlets and JSP】笔记17:JSP所生成的servlet相关问题的更多相关文章

  1. Python学习笔记17:标准库之数学相关(math包,random包)

    前面几节看得真心累.如今先来点简单easy理解的内容. 一 math包 math包主要处理数学相关的运算. 常数 math.e   # 自然常数e math.pi  # 圆周率pi 运算函数 math ...

  2. 【Head First Servlets and JSP】笔记19:JavaBeans与JSP动作元素(<jsp:setProperty.....>、<jsp:getProperty.....>)

    内容来自imooc. 1.什么是JSP动作元素 2.在JSP页面中如何使用Javabeans <jsp:......>表示这是一个JSP动作元素 3.使用JSP动作元素创建JavaBean ...

  3. Message /index.jsp (line: [17], column: [45]) The JSP specification requires that an attribute name is preceded by whitespace

    Error: Message /index.jsp (line: [17], column: [45]) The JSP specification requires that an attribut ...

  4. 超全面的JavaWeb笔记day12<Jsp&JavaBean&El表达式>

    1.JSP三大指令 page include taglib 2.9个内置对象 out page pageContext request response session application exc ...

  5. 1.3(学习笔记)JSP(Java Server Pages)内置对象

    一.内置对象 内置对象又称内建对象.隐式对象,是由服务器自动创建实例化的, 用户在使用时不需要显示的创建,可直接使用. jsp内置对象名称,类型及作用域 Scope代表该内置对象的作用范围,page表 ...

  6. JSP笔记02——概述(转)

    不完全翻译,结合谷歌,一定主观性,还可能有误,原始内容地址:https://www.tutorialspoint.com/jsp/jsp_overview.htm 主要内容如下: 什么是JSP? 为什 ...

  7. Java Web学习笔记之---JSP

    Java Web学习笔记之---JSP (一)JSP常用语法 (1)HTML注释 <!--所要注释的内容 --> 在客户端显示一个注释. (2)隐藏注释 <%--所要注释的内容--% ...

  8. [Java] JSP笔记 - Filter 过滤器

    一.什么是Web过滤器 Servlet API 很久以前就已成为企业应用开发的基石,而 Servlet 过滤器则是对 J2EE 家族的相对较新的补充. Servlet 过滤器是可插入的 Web 组件, ...

  9. jsp笔记

    Jsp  Web服务器访问jsp的过程. 如果是第一次访问jsp文件,web服务器会把jsp翻译成一个servlet文件.再将其编译成一个.class文件.然后加载到内存.蓝色的地方也是为什么jav ...

随机推荐

  1. 关于JAVA编译时找不到自定义包的问题

    这两天照网上的教程,学习JSP/SERVLET/JAVABEAN,写了几个JAVA文件,目录放在TOMCAT的WEBAPPS下面,通过javac编译时,老提示找不到指定的包: 下图是我的目录路径: 通 ...

  2. java blob

    package net.qysoft; import java.io.File;import java.io.FileOutputStream;import java.sql.Blob;import ...

  3. C#二进制序列化和反序列化

    public class WRSerializable { public static void SerializeToFile<T>(T _description, string _fi ...

  4. urllib -- ProxyHandler处理器(代理设置)

    import urllib.requestimport randomimport ssl proxy_list = [ {"https" : "196.61.27.58: ...

  5. 关于 JavaScript 学习 —— 好的博客或者网站推荐

    作者:Tw93链接:https://www.zhihu.com/question/19651401/answer/46211739来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注 ...

  6. CodeIgniter框架——源码分析之入口文件index.php

    CodeIgniter框架的入口文件主要是配置开发环境,定义目录常量,加载CI的核心类core/CodeIgniter.php.   在index.php中,CI首先做的事情就是设置PHP的错误报告, ...

  7. 回溯法——n后问题

    问题描述: 在n*n的棋盘上放置彼此不受攻击的n个皇后.按照国际象棋的规则,皇后可以攻击与之处在同一行或同一列或同一斜线上的棋子.n后问题等价于在n*n格的棋盘上放置n个皇后,任何2个皇后不放在同一行 ...

  8. js判断选择的时间是否大于今天

    获取的时间格式为  2012-5-28var thetime = document.getElementById("clearDate").value;var   d=new   ...

  9. cmake编译选项

    1 需求 现在已经有一个cmake工程,我想要添加-O0 -g,生成gdb的调试信息和不进行代码优化. 也就是说,我该怎样修改CFLAGS和CPPFLAGS? 2 在project后面添加 set(C ...

  10. mongodb安全配置

    1. 为数据库增加管理员 use admin db.createUser({ >user:'userName', pwd:'password', roles:[{role:'userAdminA ...