Do you need to have a jvm so you can visit web pages written in JSP?
This might sound dumb, but I need to verify one thing. Does it mean that without a java virtual machine in your computer, Java codes in your (jsp) will not work prope开发者_开发知识库rly? Thanks
If you are at server end YES you need JVM.
If you are at client end NO
server will compile {JSP and finally}[using JVM] will create HTML and send it to client as response and send you as response you don't need JVM to render HTML.
To clarify, the lifecycle of a JSP (abridged, but will help you understand) is:
1) A resource is requested by a user's browser (which may result in a request to execute a JSP).
2) The JSP is checked to see if it has changed since last compile.
3) If the JSP has changed, the JSP is code is converted into Java classes by a JSP compiler.
4) The java code is then executed to produce the HTML output.
5) The HTML output is then sent to the browser.
Therefore
From a client side - NO!. the user just sees HTML, and all they need is a browser.
From a server side - YES, and more!. You need a JVM (more specifically a JDK) and a servlet container to perform the necessary steps as outlined in the lifecycle above.
A JVM is required to compile JSP into HTML that is presented to the browser. What that means is that the server must have a JVM, but your client computer does not require a JVM. The HTML produced by the compiled JSPs will be read by any browser
You need Servlet/JSP container on server side. Due to servlet container is written in java you need jvm on server side too. JSP just creates HTML content dynamically, so you need HTML browser only on client side. If the generated HTML code refers to plugings you need these plugins on client side. For example you need Flash to play FLV files and Java plugin (e.g. JVM) to run java. But it does not depend on technology that is used on server side.
Do you need to have a jvm so you can visit web pages written in JSP?
For the server-side, that is correct. For the client-side, it is incorrect.
JSPs compile to Java, call tag classes written in Java and in some cases actually have Java code embedded in them. A JVM (or more accurately a Java execution platform) is essential on the server side to execute the resulting Java code. Indeed, it typically needs to be a JDK platform rather than a JRE platform to compile the Java source code generated by the JSP compiler. (In theory, you could get away with a JRE by precompiling all of your JSPs ... but then you lose a lot of flexibility.)
(I suppose you could quibble that it is possible to execute Java-like code on an execution platform that would not pass muster as a Java Virtual Machine ... according to Oracle's rules regarding the use of the relevant trademarks. But that's probably irrelevant to the thrust of this question.)
You don't need Java on the client (browser) side, but that is because JSPs are purely server-side entities. They should never get transmitted to the user's browser. Instead, they are executed by the server to produce HTML (or other kinds of resource) that are then transmitted to the user's browser.
精彩评论