简体   繁体   English

使用tomcat执行Web应用程序

[英]Executing web application with tomcat

I have started using tomcat 7 for few days. 我已经开始使用tomcat 7了几天。 I have tried executing many JAVA BASED web application with it. 我尝试使用它执行许多基于Java的Web应用程序。 I actually want to check the flow of the java based web applications. 我实际上想检查基于Java的Web应用程序的流程。 That means in which sequence the methods of web application get executed. 这意味着将按顺序执行Web应用程序的方法。 To do this I profile tomcat server with java profiler. 为此,我使用java profiler对tomcat服务器进行了分析。

My profiler works like this: 我的探查器的工作方式如下:

  1. I deploy war file of an application into web Apps dir of tomcat. 我将应用程序的war文件部署到tomcat的Web Apps目录中。
  2. I start the server by ./startup.sh 我通过./startup.sh启动服务器
  3. I access the application in browser and execute it. 我在浏览器中访问该应用程序并执行它。
  4. I stop the server by ./shutdown.sh . 我通过./shutdown.sh停止了服务器。

and after I stop the server, the profiler dumps the output in xml format(it shows heirarchy of methods as calling context tree).(MY profiler basically profiles methods of java classes.) 在我停止服务器后,事件探查器以xml格式转储输出(它显示方法的层次结构作为调用上下文树)。(MY事件探查器基本上是对Java类的方法进行探查。)

As you know, may be because Tomcat is based on servlet, for 2 exactly same runs of an application(I follow above 4 steps 2 times and have 2 different output for 2 same runs), profiler gives different outputs. 如您所知,可能是因为Tomcat基于servlet,对于应用程序的2个完全相同的运行(我在上面的4个步骤中执行了2次,对于2个相同的运行有2个不同的输出),探查器给出了不同的输出。 Q.1) I dont exactly know why this happens would be very curious to know the reason behind it. Q.1)我不十分清楚为什么会发生这种情况,所以很想知道其背后的原因。

Also the output is very large (around 200 MB) even for simple application. 此外,即使对于简单的应用程序,输出也非常大(大约200 MB)。 To limit the size of the output and to have same outputs for 2 exactly same runs, I have excluded methods of org.apache.* from profiling. 为了限制输出的大小并为2个完全相同的运行提供相同的输出,我从配置文件中排除了org.apache。*方法。 Because I am ultimately interested in knowing the flow of the web application itself.(to know in which sequence methods of web application get executed). 因为我最终对了解Web应用程序本身的流程很感兴趣。(以了解Web应用程序的方法以什么顺序执行)。 For this scenario I have following questions. 对于这种情况,我有以下问题。

Q.2) Running application by deploying war file and running it by fetching it form the directory itself can make difference in the output of the profiler ? Q.2)通过部署war文件运行应用程序,并通过从目录本身获取文件来运行应用程序,这可以使探查器的输出有所不同。 or can it affect a sequence of methods in which they execute in both the cases ? 还是会影响在两种情况下它们执行的方法序列?

Q.3) I would like to know what happens when I execute jsp page of an application ? Q.3)我想知道在执行应用程序的jsp页面时会发生什么? I mean how does tomcat execute them? 我的意思是tomcat如何执行它们? step wise please.... 请一步一步....

Q.4) when I check the output of the profiler after executing an application, I see large no of methods from org/eclipse/jdt/internal/... get executed. 问题4)当我执行的应用程序后检查探查器的输出,我看到大量的无组织从方法/月食/ JDT /内部/ ...得到执行。 So what do this classes do actually ? 那么,这些课程实际上是做什么的呢? Why do I have them in my output ? 为什么要在输出中包含它们?

Please let me know if I have failed to explain my questions. 如果我未能解释我的问题,请告诉我。 I kiind of searched a lot but could not find very precise answers to my questions. 我很想搜索,但是找不到我问题的非常准确的答案。

I would really appreciate your responses.. 非常感谢您的回复。

Thanks you. 谢谢。

I strongly recommend to read a bit about tomcat works. 我强烈建议您阅读一些有关tomcat的作品。 In short 简而言之

Q.2 Shouldn't make any difference. Q.2不应有任何区别。

Q.3 JSPs are compiled to servlet classes when they get called. Q.3 JSP在被调用时被编译为Servlet类。 If there is no Servlet class for the JSP tomcat makes one. 如果没有用于JSP的Servlet类,tomcat会创建一个。 If there is a corresponding servlet class, tomcat looks which one is younger, the JSP or the servlet. 如果有相应的servlet类,则tomcat会查找哪个是年轻的JSP或servlet。 If the JSP is younger it does a new compilation, if not it uses the servlet. 如果JSP较新,它将进行新的编译,否则,将使用servlet。

Q.1 Not sure. Q.1不确定。 Could be a multithreading/timing thing, Maybe it's the way your profiler works. 可能是多线程/定时的事情,也许这就是您的探查器的工作方式。

Q.4 Not sure. Q.4不确定。 Could a be classes from the profiler or libraries used by your servlet code? 可能是servlet代码使用的探查器或库中的类吗?

EDIT : For Q.4 look at Ian Roberts' comment to the question. 编辑 :对于Q.4,请看Ian Roberts对问题的评论。

What profiler do you use? 您使用什么探查器? How about going stepwise through the code by debugging it? 如何通过调试逐步浏览代码?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM