What is the difference between JavaScript and JSP?

Source: Internet
Author: User

Name:
Js:javascript
Jsp:java Server Pages

Execution process: JSP first translated, translated into servlet execution
such as: test.jsp to become Test_jsp.java and then compiled into Test_jsp.class
And Test_jsp.java itself is a servlet.
So JSP is just a variant of the servlet, convenient to write HTML content only appears.
Servlets are fundamental, all JSPs can do, and the servlet is all-rounder.
JS: Is an object-based client-side scripting language. The goal is to resolve the server-side language.
such as: Perl, the legacy of speed issues, to provide customers with smoother browsing results.
JS can be embedded directly into the HTML code for parsing execution,
Very simple and easy to learn, can produce a lot of dynamic effect.

Image comparison: JS is executed at the client and requires a browser to support JavaScript. JSP is executed on the server side,
Server programs that support Servlets need to be deployed on the server. JS code can be directly from the server
On download, external is visible, JSP (and translated servlet code) is not visible to the outside world.

JS and JSP compared: Although JS can be the client dynamically generated HTML, but it is difficult to interact with the server, therefore can not provide complex
The service.
Such as: access to database and image processing and so on.
JSP is implemented in HTML with <%%>. JS is implemented in HTML with <Scrippt></Script>.

Execution process:
Jsp:
1. The JSP file is compiled into a servlet when the user first requests it, and is then processed by this servlet
User's request, so the servlet can be seen as a runtime servlet.
2, JSP container is the servlet container management JSP page life cycle is divided into two stages, that is, the transformation phase and execution phase.
3, Conversion stage: When a request to the JSP page arrives, the JSP container checks the JSP page syntax is correct, the JSP page
Convert to a servlet source file, and then call the Javac command to compile the servlet source file to generate the bytecode file.
4. Execution phase: The servlet container loads the transformed Servlet class.
Js:
JavaScript is usually run in the foreground, that is, running in the user's browser, usually does not need the server's background support (Ajax
exceptions), JavaScript scripts mixed in HTML are interpreted directly by the browser to improve the aesthetics of the page and
The UI action response speed is the basic goal. (Different running locations)

Different Run locations:
JSP runs on a background server, Java program segments mixed in HTML are used to control the dynamic generation of HTML and are usually responsible for invoking the background
The data in the database forms a page that has a rich data interaction effect based on the changes in usage.

What is the difference between JavaScript and JSP?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.