jsp编译后的文件位置(Eclipse和tomcat)

java web开发人员都知道,jsp其实是转化成java代码,通过out.write()的方式生成页面。今天想看看转化的java源代码,通过查找发现Eclipse和tomcat的存储在不同的位置:
jsp其实是转化成java代码(通过tomcat将.jsp转换成.java同时还生成了.class(运行))
【Eclipse】

<workspace所在目录>.metadata.plugins\org.eclipse.wst.server.core\tmpX\work\Catalina<项目名称>
eg:E:\eclipseProject.metadata.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\hh\org\apache\jsp


image.png

jsp.java内容如下:
/*

  • Generated by the Jasper component of Apache Tomcat
  • Version: Apache Tomcat/7.0.88
  • Generated at: 2018-07-19 02:22:57 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 NewFile_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 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() {
}

public void _jspDestroy() {
}

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=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\n");
  out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\r\n");
  out.write("<html>\r\n");
  out.write("<head>\r\n");
  out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\r\n");
  out.write("<title>Insert title here</title>\r\n");
  out.write("</head>\r\n");
  out.write("<body>\r\n");
  out.write("\t<form action=\"TestServlet\" method=\"post\">\r\n");
  out.write("\t\t<input type=\"text\" name=\"name\"> <input type=\"submit\"\r\n");
  out.write("\t\t\tvalue=\"submit\">\r\n");
  out.write("\t</form>\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);
}

}
}
jsp.class内容如下:(通过反编译工具jd-gui)
package org.apache.jsp;

import java.util.Map;
import javax.el.ExpressionFactory;
import javax.servlet.ServletConfig;
import javax.servlet.jsp.JspApplicationContext;
import javax.servlet.jsp.JspFactory;
import org.apache.jasper.runtime.HttpJspBase;
import org.apache.jasper.runtime.InstanceManagerFactory;
import org.apache.jasper.runtime.JspSourceDependent;
import org.apache.tomcat.InstanceManager;

public final class NewFile_jsp
extends HttpJspBase
implements JspSourceDependent
{
private static final JspFactory _jspxFactory = ;
private static Map<String, Long> _jspx_dependants;
private volatile ExpressionFactory _el_expressionfactory;
private volatile InstanceManager _jsp_instancemanager;

public Map<String, Long> getDependants()
{
return _jspx_dependants;
}

public ExpressionFactory _jsp_getExpressionFactory()
{
if (this._el_expressionfactory == null) {
synchronized (this)
{
if (this._el_expressionfactory == null) {
this._el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
}
}
}
return this._el_expressionfactory;
}

public InstanceManager _jsp_getInstanceManager()
{
if (this._jsp_instancemanager == null) {
synchronized (this)
{
if (this._jsp_instancemanager == null) {
this._jsp_instancemanager = InstanceManagerFactory.getInstanceManager(getServletConfig());
}
}
}
return this._jsp_instancemanager;
}

public void _jspInit() {}

public void _jspDestroy() {}

/* Error */
public void _jspService(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
throws java.io.IOException, javax.servlet.ServletException
{
// Byte code:
// 0: aconst_null
// 1: astore 4
// 3: aconst_null
// 4: astore 5
// 6: aconst_null
// 7: astore 6
// 9: aload_2
// 10: ldc 85
// 12: invokeinterface 87 2 0
// 17: getstatic 26 org/apache/jsp/NewFile_jsp:_jspxFactory Ljavax/servlet/jsp/JspFactory;
// 20: aload_0
// 21: aload_1
// 22: aload_2
// 23: aconst_null
// 24: iconst_1
// 25: sipush 8192
// 28: iconst_1
// 29: invokevirtual 93 javax/servlet/jsp/JspFactory:getPageContext (Ljavax/servlet/Servlet;Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;Ljava/lang/String;ZIZ)Ljavax/servlet/jsp/PageContext;
// 32: astore_3
// 33: aload_3
// 34: astore 6
// 36: aload_3
// 37: invokevirtual 97 javax/servlet/jsp/PageContext:getServletContext ()Ljavax/servlet/ServletContext;
// 40: pop
// 41: aload_3
// 42: invokevirtual 100 javax/servlet/jsp/PageContext:getServletConfig ()Ljavax/servlet/ServletConfig;
// 45: pop
// 46: aload_3
// 47: invokevirtual 101 javax/servlet/jsp/PageContext:getSession ()Ljavax/servlet/http/HttpSession;
// 50: pop
// 51: aload_3
// 52: invokevirtual 105 javax/servlet/jsp/PageContext:getOut ()Ljavax/servlet/jsp/JspWriter;
// 55: astore 4
// 57: aload 4
// 59: astore 5
// 61: aload 4
// 63: ldc 109
// 65: invokevirtual 111 javax/servlet/jsp/JspWriter:write (Ljava/lang/String;)V
// 68: aload 4
// 70: ldc 116
// 72: invokevirtual 111 javax/servlet/jsp/JspWriter:write (Ljava/lang/String;)V
// 75: aload 4
// 77: ldc 118
// 79: invokevirtual 111 javax/servlet/jsp/JspWriter:write (Ljava/lang/String;)V
// 82: aload 4
// 84: ldc 120
// 86: invokevirtual 111 javax/servlet/jsp/JspWriter:write (Ljava/lang/String;)V
// 89: aload 4
// 91: ldc 122
// 93: invokevirtual 111 javax/servlet/jsp/JspWriter:write (Ljava/lang/String;)V
// 96: aload 4
// 98: ldc 124
// 100: invokevirtual 111 javax/servlet/jsp/JspWriter:write (Ljava/lang/String;)V
// 103: aload 4
// 105: ldc 126
// 107: invokevirtual 111 javax/servlet/jsp/JspWriter:write (Ljava/lang/String;)V
// 110: aload 4
// 112: ldc -128
// 114: invokevirtual 111 javax/servlet/jsp/JspWriter:write (Ljava/lang/String;)V
// 117: aload 4
// 119: ldc -126
// 121: invokevirtual 111 javax/servlet/jsp/JspWriter:write (Ljava/lang/String;)V
// 124: aload 4
// 126: ldc -124
// 128: invokevirtual 111 javax/servlet/jsp/JspWriter:write (Ljava/lang/String;)V
// 131: aload 4
// 133: ldc -122
// 135: invokevirtual 111 javax/servlet/jsp/JspWriter:write (Ljava/lang/String;)V
// 138: aload 4
// 140: ldc -120
// 142: invokevirtual 111 javax/servlet/jsp/JspWriter:write (Ljava/lang/String;)V
// 145: aload 4
// 147: ldc -118
// 149: invokevirtual 111 javax/servlet/jsp/JspWriter:write (Ljava/lang/String;)V
// 152: aload 4
// 154: ldc -116
// 156: invokevirtual 111 javax/servlet/jsp/JspWriter:write (Ljava/lang/String;)V
// 159: goto +105 -> 264
// 162: astore 7
// 164: aload 7
// 166: instanceof 142
// 169: ifne +71 -> 240
// 172: aload 5
// 174: astore 4
// 176: aload 4
// 178: ifnull +37 -> 215
// 181: aload 4
// 183: invokevirtual 144 javax/servlet/jsp/JspWriter:getBufferSize ()I
// 186: ifeq +29 -> 215
// 189: aload_2
// 190: invokeinterface 148 1 0
// 195: ifeq +11 -> 206
// 198: aload 4
// 200: invokevirtual 152 javax/servlet/jsp/JspWriter:flush ()V
// 203: goto +12 -> 215
// 206: aload 4
// 208: invokevirtual 155 javax/servlet/jsp/JspWriter:clearBuffer ()V
// 211: goto +4 -> 215
// 214: pop
// 215: aload 6
// 217: ifnull +13 -> 230
// 220: aload 6
// 222: aload 7
// 224: invokevirtual 158 javax/servlet/jsp/PageContext:handlePageException (Ljava/lang/Throwable;)V
// 227: goto +13 -> 240
// 230: new 83 javax/servlet/ServletException
// 233: dup
// 234: aload 7
// 236: invokespecial 162 javax/servlet/ServletException:<init> (Ljava/lang/Throwable;)V
// 239: athrow
// 240: getstatic 26 org/apache/jsp/NewFile_jsp:_jspxFactory Ljavax/servlet/jsp/JspFactory;
// 243: aload 6
// 245: invokevirtual 164 javax/servlet/jsp/JspFactory:releasePageContext (Ljavax/servlet/jsp/PageContext;)V
// 248: goto +24 -> 272
// 251: astore 8
// 253: getstatic 26 org/apache/jsp/NewFile_jsp:_jspxFactory Ljavax/servlet/jsp/JspFactory;
// 256: aload 6
// 258: invokevirtual 164 javax/servlet/jsp/JspFactory:releasePageContext (Ljavax/servlet/jsp/PageContext;)V
// 261: aload 8
// 263: athrow
// 264: getstatic 26 org/apache/jsp/NewFile_jsp:_jspxFactory Ljavax/servlet/jsp/JspFactory;
// 267: aload 6
// 269: invokevirtual 164 javax/servlet/jsp/JspFactory:releasePageContext (Ljavax/servlet/jsp/PageContext;)V
// 272: return
// Line number table:
// Java source line #65 -> byte code offset #0
// Java source line #67 -> byte code offset #3
// Java source line #68 -> byte code offset #6
// Java source line #72 -> byte code offset #9
// Java source line #73 -> byte code offset #17
// Java source line #74 -> byte code offset #23
// Java source line #73 -> byte code offset #29
// Java source line #75 -> byte code offset #33
// Java source line #76 -> byte code offset #36
// Java source line #77 -> byte code offset #41
// Java source line #78 -> byte code offset #46
// Java source line #79 -> byte code offset #51
// Java source line #80 -> byte code offset #57
// Java source line #82 -> byte code offset #61
// Java source line #83 -> byte code offset #68
// Java source line #84 -> byte code offset #75
// Java source line #85 -> byte code offset #82
// Java source line #86 -> byte code offset #89
// Java source line #87 -> byte code offset #96
// Java source line #88 -> byte code offset #103
// Java source line #89 -> byte code offset #110
// Java source line #90 -> byte code offset #117
// Java source line #91 -> byte code offset #124
// Java source line #92 -> byte code offset #131
// Java source line #93 -> byte code offset #138
// Java source line #94 -> byte code offset #145
// Java source line #95 -> byte code offset #152
// Java source line #96 -> byte code offset #159
// Java source line #97 -> byte code offset #164
// Java source line #98 -> byte code offset #172
// Java source line #99 -> byte code offset #176
// Java source line #101 -> byte code offset #189
// Java source line #102 -> byte code offset #198
// Java source line #103 -> byte code offset #203
// Java source line #104 -> byte code offset #206
// Java source line #106 -> byte code offset #211
// Java source line #107 -> byte code offset #215
// Java source line #108 -> byte code offset #230
// Java source line #111 -> byte code offset #240
// Java source line #110 -> byte code offset #251
// Java source line #111 -> byte code offset #253
// Java source line #112 -> byte code offset #261
// Java source line #111 -> byte code offset #264
// Java source line #113 -> byte code offset #272
// Local variable table:
// start length slot name signature
// 0 273 0 this NewFile_jsp
// 0 273 1 request javax.servlet.http.HttpServletRequest
// 0 273 2 response javax.servlet.http.HttpServletResponse
// 32 20 3 pageContext javax.servlet.jsp.PageContext
// 1 206 4 out javax.servlet.jsp.JspWriter
// 4 169 5 _jspx_out javax.servlet.jsp.JspWriter
// 7 261 6 _jspx_page_context javax.servlet.jsp.PageContext
// 162 73 7 t Throwable
// 251 11 8 localObject Object
// 214 1 9 localIOException java.io.IOException
// Exception table:
// from to target type
// 9 159 162 java/lang/Throwable
// 189 211 214 java/io/IOException
// 9 240 251 finally
}
}
经过对比,发现tomcat中的内容与eclipse完全一样(应该是一样的,因为我用的是相同的tomcat7)
【tomcat】

<tomcat所在目录>\work\Catalina\localhost<项目名称>

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 194,524评论 5 460
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 81,869评论 2 371
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 141,813评论 0 320
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 52,210评论 1 263
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 61,085评论 4 355
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 46,117评论 1 272
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 36,533评论 3 381
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 35,219评论 0 253
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 39,487评论 1 290
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 34,582评论 2 309
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 36,362评论 1 326
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,218评论 3 312
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 37,589评论 3 299
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 28,899评论 0 17
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,176评论 1 250
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 41,503评论 2 341
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 40,707评论 2 335

推荐阅读更多精彩内容

  • 小编费力收集:给你想要的面试集合 1.C++或Java中的异常处理机制的简单原理和应用。 当JAVA程序违反了JA...
    八爷君阅读 4,544评论 1 114
  • 1. Java基础部分 基础部分的顺序:基本语法,类相关的语法,内部类的语法,继承相关的语法,异常的语法,线程的语...
    子非鱼_t_阅读 31,504评论 18 399
  • 每个使用Java的开发者都知道Java字节码是在JRE中运行(JRE: Java 运行时环境)。JVM则是JRE中...
    燕京博士阅读 1,373评论 0 6
  • 敬笃 在北方,秋天的颜色,总会在不合时宜的冬天被人看淡,斑斓的色彩化作枯木,瑟瑟的站立于雪花之中。 摄氏零下二十度...
    山谷小道士阅读 496评论 2 2
  • 他总是那么缥缈.
    复旦校草的女友阅读 110评论 0 0