JSP JS Java

Source: Internet
Author: User
Tags microsoft iis

Java Technology
J a V A is an easy-to-use, fully object-oriented, platform-independent, and safe and reliable main oriented i n T e R n E t
Hair Tools. Since its inception in 1 9 9 5, the rapid development of J a V A has revolutionized the entire we B world.
With the introduction of Java servlet, J a V A is emerging in e-commerce and the latest Java Server page technology pushes
To make J a V a The preferred development tool for our application based on we B.
To learn the Java Server page,j a V a foundation in J A V a technology is essential, this book will be in the 2nd chapter without J a V a
Basic readers are simply explaining the basic syntax of J a v A and Java beans, which are the J a V a knowledge that must be mastered before learning J S P.
Here, let's review the history of J a V A, and then explain some important concepts that will be used later.
1.1.2 JavaBeans
J A V a B e a n s is a reusable component technology for J A V A. A S P expands complex functions with C O m,
such as file upload, send e m a i l and separate business processing or complex calculations into separate reusable modules. J S P-Pass
The same function expansion is achieved with J A V a B e a n. JSP provides a perfect support for integrating JavaBean components in Web applications.
Hold. This support not only shortens development time (it is possible to directly leverage the tested and trusted components, avoiding repetitive
Also provides more scalability for JSP applications. JavaBean components can be used to perform complex computational tasks, or negative
2 Count the first part of JSP getting Started
Download
database, and data extraction.
In the actual J s P development process, readers will find that the J s P page will be a non-
Often concise, because J a v a B e a n s is simple to develop and can take advantage of the powerful features of J a V a language, many dynamic page processing
The process is actually encapsulated in J a V a B e a n s.
1.1.3 JDBC
J D B C is a J a V a application interface for executing the S Q L statement, consisting of a set of classes and interfaces written in J A V a language,
In J S p The database will be accessed using J D B c. J D B C is a specification that allows each database vendor to provide a programmer for J a V A
Database access classes and interfaces, which makes it possible to develop tools and products that are independent of the D B M s for J a V a applications.
The General J A V a development tool has a J D b c-o D C Bridge driver so that data accessed with O D b C can be used as long as
Library system, you can also access it using J D B c. Interestingly, unlike O D B C, which is open Database connectivity
For short, J D B c is not the abbreviation for Java Database connecivity, but a registered trademark of S U N, at least the official claim is that
Kind of.
1.1.6 Java Servlet
Java servlet is the foundation of J s P technology, and the development of large we B applications requires Java servlet and J s p mates
To complete, here is a brief introduction to the knowledge of S E R v L e T, the development of S E R v L e t will be described in the second part.
S e R v L e t this name probably originates from a P p l e T, now there are many ways of translation in the country, this book in order to avoid misunderstanding, decided directly
Using S e r v l e t without any translation, readers can call it a "small service program" if they wish. S e R v L e T in fact and traditional
C G I Program and I s a P I, N s a P I and other we B program development tools are the same, after using the Java servlet, the user
There is no need to use the inefficient C-G I approach, nor do I have to use a P I mode that can only be run on a fixed we B server platform
Dynamically generate the We B page. Many we B servers support the S E R v L e T, even if you do not directly support the S E R v L e T Server can also
Support for S E R v L e T through additional application servers and modules. Thanks to the cross-platform characteristics of J A V A, the S e R v L e T is platform Independent
, in fact, as long as the Java servlet specification is met, S e R v L e T is completely platform independent and is independent of the We B server. Because
The Java servlet internally provides services in a threaded manner, without having to start a process for each request and taking advantage of multithreading
The mechanism can serve multiple requests at the same time, so the Java servlet is very efficient.
But Java servlet is not without disadvantage, and the traditional C G I, I s a P I, N s a P i way, Java servlet is
Using the output H T M statement to implement dynamic Web pages, if you use Java servlet to develop the entire site, dynamic parts and static pages
The integration process of the face is a nightmare. This is why S U N also launches the Java Server pages.
1.2 JSP Technology
As mentioned earlier, the biggest disadvantage of Java servlet is that it does not separate the logic of the Web site from the output of the page, causing the entire
S e R v L e T code chaotic. To address this disadvantage of the Java servlet, S U N introduced the Java Server pages-j s P.
1.2.1 JSP Technology Overview
According to the script language is the language that serves a certain subsystem, J S p should be considered as a scripting language, but
And, as a scripting language, J s p appears to be too powerful to use almost all J A V Class A in J s p.
Chapter I Overview of the total 9
Download
As a text-based, display-centric development technique, J S p provides all the benefits of the Java Servlet, and
When combined with a JavaBeans class, provides a simple way to separate the content from the display logic. Separate content
and display logic, the benefit is that people who update the appearance of the page do not have to understand Java code, and those who update J a v a B e a N s class are not
Must be the designer of the Web page, you can use the JSP page with the JavaBeans class to define the Web Template to create a
A web site that has a similar appearance of pages. The JavaBeans class completes the data supply so that there is no Java code in the template,
This means that these templates can be maintained by an HTML writer. Of course, Java Servlets can also be used to control the network
The logic of the station and the way the Java servlet invokes the J S p file to separate the logic and content of the Web site. Later in this chapter we will
This separation of the logic and content of the site design method to do some more in-depth description.
When choosing to use a Java servlet or a JSP page, keep in mind that the Java servlet is a program
Design tool, which is most suitable for low-level application functions that do not require frequent modification; The J S P page is represented by a display-centric description
The dynamic content and logic are combined in a sexual approach. For a simple web-based application that uses a JSP page,
Instead of using the JavaBeans class to combine content with application logic, you can use custom tags or S c r I p t l e T. Custom
Tags are packaged in a tag library and introduced into a JSP page. S c R I p t l e T is directly embedded in the JSP page
Very small J A v a code segment.
In general, in the actual J s P engine, the J s P page executes as a compiler rather than an explanatory one. of the explanatory type
Dynamic Web development tools such as a S p, p H p 3 and so on due to speed and other reasons have not satisfied the current large-scale e-commerce applications need
, the traditional development techniques are changing to the way the compiler executes, such as A s p→a s P +;p h p 3→p h p 4. And although J S P's
The specification does not require the actual J S P engine to use a compiled execution method, but the estimate is generally not to use the interpreted party
To execute the J S P page. Generally speaking, the J S P page is usually a J a V source file translated as S e R v L e T, and then the J a v a compiler
C L A s S file compiled to S e R v L e T. Why compile to S E R v L e t? It is said to allow the original S E R v L e T engine to directly
For J s P, the J s P engine only needs to translate J s p to s e R v L e T. Here is the note: J S P Specification Book
There is no rule on how to translate J s p pages into S e R v L e T, so the results of different J s P engine translations are not the same.
After the J s P file is translated to S e R v L e T, each client (usually the user's we B browser) requests this J s p to the server
File, the server will check that the J S p file has changed since the last compilation, and if it has not changed, execute it directly
S e R v L e t without recompiling, its efficiency is quite high. In general, the compilation of J S p files is the first user to visit a
This occurs when the J S P page is asked, and the first user is usually the developer himself, so that it is formally placed on the server for
The J s P file accessed by the user generally has the corresponding compiled S e r v L e T. Many servers have settings that allow J S P
Files are pre-compiled before the first user accesses them, so it seems that the efficiency is even higher. Later in the 4th chapter, we will show
A simple J s p file corresponds to the S e R v L e T.
In the J s p Specification book, there is no explicit requirement that the part of the program code in J s p (called S C r I p t l e T) must be written with J a V A,
In fact, there are some J S p engines that are used in other scripting languages, such as: E M A c-s C r I p t, We b L and so on, but actually these
The scripting language is also built on J A V A, compiled to S e R v L e T to achieve. According to the J S P specification book, The complete and J a V A does not have any
The S C R I p t l e T is also possible, however, because the power of J S P is mainly in the ability and J a V a B e a n S, Enterprise JavaBeans
Work together, so even if the scriptlet part does not use Java, the compiled execution code should also be Java-related.
Advantages of 1.2.2 JSP and comparison with other we B development tools
Compared with the traditional C-G I, J S p has considerable advantages. First, in terms of speed, the traditional C-G I program needs to use the system
10 count the first part of JSP getting Started
Download
Standard input to generate dynamic Web pages, while J S p is directly associated with the server. And for C G I to
That each visit requires a new process to be processed, and the process is constantly building and destroying the
The computer will be a burden. Secondly, J S P is designed specifically for the development of We b, and its purpose is to establish
A complete set of specifications and tools is included in the program. J s P Technology makes it easy to combine a large set of J s p pages into a
A We-B application.
Compared with i s PA I and n s A P i, J S p develops much faster and is much less difficult to develop, and is compiled to J a V a
After S e R v L e T, the J a V a interpreter with the latest J I T (Just in Ti m e) is not performing much slower. and
And, I s a P I and N s a P I this and we B server too tightly combined with the technology in use when the error occurs, it is easy to make
We b server crashes, and J S P does not have this disadvantage.
The real opponent of J s p is a s p and P H p, as well as the upcoming a s p +, the ratio of a s p, p H p and J s p in the We-B technology
See table 1-1.
Note: A s p here refers to a s P 3. 0,j s p refers to J s p Specification Book 1. The specification indicated in 1, p H p refers to P H p 4.
Table 1-1 ASP, J S p, p H p comparison
A s P J s p p H p
We b Server I i S, p w s etc a p a c h e, I i S, P W s,
Netscape server and so on
Running platform wi n d o w s etc various u n I x (S o l a R i s, l I n u X,
A i x, I R i x, etc.), Wi n d o W S
Component technology c o m etc c o m, J a V a B e a n s
Custom TA g syntax no equal no
Open, non-free software
Scripting language Support V B s C r i p T, J S C R I p t etc p H p
The establishment of large we B applications can wait for inappropriate
Very fast program execution speed
Low Learning Difficulty
S e s S i o n management there are etc.
Unified database Connection Yes, a d o, o d B C, etc. none
Suffix a s p etc p h p, p h p 3, p H p s
1. We b server and operating platform
A S P is currently only supported on Microsoft Internet Information Server (I I S) and personal Web server
(P W s), because I I S and P W s only have a version of WI n d o w S, so a s P is currently only available under the WI n d o w s platform. Do
A plug-in with third-party claims can use a s p under U N I x, but for a s p based on C O M component technology, there is no
C O m supported under the U N I x platform can only be a "toy".
J s P is only a specification, although it is possible to conclude from the previous discussion that J s p is generally made by J a V A, but as
Cross-platform language, J a V A can be used on many platforms. In this way, J S P is obviously cross-platform. The current
Chapter I Overview of the total 11
Download
such as a p a c h e, I i S, P W S,
Netscape Server, I P l a n e t
such as
And so on various U N I X (S o l a R I s,
L n u x, A i x, I R i x, etc.),
Wi n d o w S, M a c o s etc.
J A V a B e a n s, E J B
Wait a
And many other cooperation, including S U N,
I b M, BEA We b l o g i c,
N e t s c a P E, O R a C l E
J A V A, E M a c-s C r I p t,
We b L etc
Wait, yes.
Wait very fast
and other lower
Wait a
ET, J D B C
Et J s P
J S P can indeed be used under a variety of We B servers and operating systems. such as Apache WEB Server and Microsoft IIS.
Apache Web Server is the world's most-occupied we B server product and can be included in the Sun Solaris, I b M
A I x, SGI IRIX, L I n u X and wi n d o w s run under many operating systems. The implementation of J S p under Apache Web server
can now be implemented with free Apache Jserv and G n u J S P, J a k a r T a-to M c a T, or commercial J R U N
(L i v e S o f t w a r e), we b L o g i c (b e a), we b S P h e r E (i b M) to achieve.
Microsoft IIS itself does not directly support J S p, but can be achieved by J R U N, we b l o g i c, we b S P h e R E.
You can also use the application server to add Netscape Enterprise Server supported by J S P and the development of it can be directly
Support for J S P iplanet Web Server and so on.
P H p itself supports various operating systems and we b servers, and P H p is currently available as an additional modulo for a p a C H E
Block is directly compiled into a p a C h e, since a p a c H e supports a variety of operating systems, p H p can also be used in various operations
Implemented on the system. P H p can also be either C G I mode or i s A P i way inserted into I I S or P W s.
2. Component Technology
A S p and J s P support for component technology is well established, and P H p does not begin to support C O M and J A V a B e a n S until shortly before.
However, the support is not perfect, if p H p cannot improve the support of component technology in the future, the large we b application will
It is difficult to compete with J s P and a S p. But because the P H p technology itself is easy to learn and use, plus a number of function support and open source code
Features, p H p will still occupy a place in the development of small and medium we B sites.
In fact, J s P itself has no obvious advantage for a S p and P H p, and the strength of J s p is that it has a strong J a V a technology behind it.
To support the operation. J-a V a technology, including J A V a B e a n S and J 2 e E technology, is where J S p is powerful.
M i c R o s o f t the latest a s p + technology and a s p technology have a lot of exciting progress, but from the enterprise level should be
From the point of view, J S P technology still has a considerable advantage. There is reason to believe that in future we b development, small and medium-sized sites will be
Now J s P, A S p + and p H p three points to the world, but for large e-commerce sites, J s P and J 2 e E technology will be the first

Choose.

The entry is compiled from Hamal collection of online data.

I hope you will be able to distinguish between JS (JavaScript) and JSP (Java Server Pages) after reading this entry.

I hope these two documents will be helpful to everyone!

............................................................................................................

Introduction to JavaScript

Hyper Text and Hypermedia (Hyper Media) technology combined with hyperlinks (Hyper link)

Information is organized into a network structure (web) that forms a network document that enables "roaming" on the internet. With HTML characters

Can realize the retrieval of multimedia information such as text, table, sound, image and animation.

However, the use of this super-chain technology has some shortcomings, that is, it can only provide a static information resources, the lack of dynamic

Client-side interaction with the server. Although the CGI (Common Gateway Interface) Universal Gateway Interface enables certain

, but because of the complexity of programming, this method has prevented the development of Internet technology for some time. and JavaScript's Out

Now, no condensation has brought chance to internet users. It can be said that the advent of JavaScript is the demand of the times, is when

This information age has created JavaScript.

The advent of JavaScript, which allows information and users not only a display and browsing relationship, but to achieve a

Real-time, dynamic, and capable of communication. Thus, CGI-based static HTML pages will be able to provide dynamic real-time information and

A replacement for a Web page that responds to customer actions. JavaScript scripts are the language that is created to meet this need. It is widely

Popular welcome for pan-users. It is a very good one in many scripting languages, and its combination with WWW effectively realizes the network computing

And a blueprint for networked computers. The non-condensing Java family occupies the dominant position of Internet networks. So as soon as the JavaScript is mastered

Scripting language programming method is a growing concern of our customers.

First, the history of JavaScript

Referring to the history of JavaScript, we first have to introduce [Netscape] (Netscape) This company, I believe many people have used

Netscape browser to browse the Web, this company in the design of the browser, on the one hand in order to assist itself in the development of a name called

Livewire program, on the other hand to improve the interactivity of web design, so the development of LiveScript this computer language.

What does JavaScript have to do with LiveScript? At the same time as the development of LiveScript in Netscape, another company called [l

Yang] (Sun) company is also developing the Java language, in order to support Java Web programming aspects of the design, so the two companies into

Co-development of LiveScript language, and renamed LiveScript language Javacript, which is Javacript's

Origin.

JavaScript was only initially applied to the Netscape browser, but as the people who made the pages with JavaScript are increasingly

, Microsoft's IE browser also provides new features, now you can see the effect of JavaScript on IE browser.


Second, what is JavaScript

JavaScript is a scripting language that is Object-based (objects) and event-driven (driven) and has security performance. Use

It is designed to be linked in a Web page with HTML Hypertext Markup Language, Java scripting language (Java applet)

Multiple objects, interacting with web customers. So that you can develop client applications and so on. It is either embedded or transferred into the standard

Implemented in the HTML language. Its appearance makes up for the HTML language flaw, it is the Java and the HTML compromise choice, has the following several

Basic Features:

1, is a scripting language
JavaScript is a scripting language that implements programming in the form of a small program segment. Like other scripting languages, JavaScript

As an explanatory language, it provides an easy development process.
Its basic structure form and C, C + +, VB, Delphi very similar. But unlike these languages, it needs to be compiled first, but in

The program is interpreted on a row-by-line basis during operation. It is combined with the HTML identity to facilitate the user's use of the operation.

2. Object-based language.
JavaScript is an object-based language that can be viewed as an object-oriented one. This means that it can use its own

The created object. Therefore, many functions can be derived from the interaction of the methods of the objects in the scripting environment with the script.

3. Simplicity
The simplicity of JavaScript is mainly reflected in the following: First, it is a simple and compact design based on Java Basic statement and control flow.

A very good transition for learning java. Second, its variable type is weakly typed and does not use a strict number

Data type.

4. Security
JavaScript is a security language that does not allow access to local hard disks, does not store data on the server, and does not allow

Modify and delete the Web documents, only through the browser to achieve information browsing or dynamic interaction. To effectively prevent data loss.

Lost.

5, the dynamic nature of
JavaScript is dynamic, and it can respond directly to user or customer input without having to go through a Web service program. It to the user's

The response is reflected in an event-driven manner. The so-called event-driven, that is, in the homepage (home page) performed a

The action generated by the operation is called an "event". such as pressing the mouse, moving the window, selecting the menu, etc. can be considered as

Event. When an event occurs, a corresponding event response may be caused.

6. Cross-platform
JavaScript is dependent on the browser itself, regardless of the operating environment, as long as the browser can run the computer and support

JavaScript's browser can execute correctly. Thus realized the "write once, traveled the world" dream.

In fact, the best thing about JavaScript is that you can do a lot of things with very small programs. Without the need for high-performance computers, the software requires only

A word processing software and a browser, without the Web server channel, through their own computer can do all things.

Synthesis of the JavaScript is a new description language, it can be clamped into the HTML file. The JavaScript language can

To respond to user demand events (e.g., form input) without transmitting data back and forth from any network, so when a user

When entering a data, it does not pass to the server to process, and then return the process, and directly can be the client

(client) is handled by the application.

JavaScript is similar to Java, but it's not the same! Java is a much more complex programming language than JavaScript.

JavaScript is a fairly easy-to-understand language. JavaScript creators can focus less on programming skills, so

Many Java features are not supported in Java Script.

Iii. the difference between JavaScript and Java

Although JavaScript is closely linked to Java, it is the two different products developed by the two companies. Java is the launch of sun Company

A new generation of object-oriented programming language, especially suitable for Internet application development, and JavaScript is Netscape

The purpose of the company's products is to extend the functionality of the Netscape Navigator, and a developed one can be embedded in a Web page based on

Object and event-driven explanatory language, formerly known as Live Script, and Java's predecessor is the Oak language. The following two languages

The similarities and differences between the words are compared as follows:

1. Object-based and object-oriented
Java is a true object-oriented language, and even if you are developing a simple program, you must design the object.
JavaScript is a scripting language that can be used to create complex software that is independent of the network and interacts with the user. It is a

Programming languages that are based on object Based and event-driven events Driver. Thus it itself offers a very rich

Internal objects for designers to use.

2. Interpretation and compilation
The two languages do not perform the same way in their browsers. Java source code must be compiled before it is delivered to the client.

The client must have an emulator or interpreter on the corresponding platform, which can be implemented by the compiler or interpreter independently of the

The binding of a particular platform compilation code.
JavaScript is an explanatory programming language whose source code is not compiled before it is sent to the client, but rather the text grid

Type of character code sent to the client to be interpreted by the browser to execute.

3. JavaScript is loosely structured, for example, before variables used in the program need to be explicitly defined, while Java and

Orthodox programming language, the structure is more rigorous.
For example: Strong variables and weak variables
The variables taken in both languages are not the same.
Java uses strongly typed variables to check that all variables must be declared before they are compiled. Such as:

Integer x;
String y;
x=1234;
x=4321;

Where the x=1234 description is an integer, the y=4321 description is a string.
A variable declaration in JavaScript with its weak type. That is, the variable does not need to be declared before it is used, but the interpreter checks it at run time

Data types, such as:

x=1234;
Y= "4321";

The former indicates that x is a numeric variable, while the latter indicates that Y is a character variable.

4, the code format is not the same
JavaScript code is a text character format that can be embedded directly into an HTML document and dynamically loaded. Writing HTML text

Files are as convenient as editing a text file. and JavaScript must be written in the HTML file, directly to view the page's original code,

Can see the JavaScript program, so there is no protection, anyone can copy the program through the HTML file.
Java is an HTML-independent format that must be loaded by referencing an external media like HTML, with code in byte code

The form is saved in a separate document. Java applications in the Web page are called Java applets (applets are [applet] meaning),

is separate from the HTML file.

5, the embedding method is not the same
In HTML documents, the identities of the two programming languages are different, JavaScript uses <Script>...</Script> to identify, and Java

Use <applet>...</applet> to identify.

6. Static linking and dynamic linking
JavaScript is a file-like description language that can be executed directly through a browser, while Java is like the Orthodox programming language

(such as C + +), you must first make Yi and links and other actions before execution.
Java uses static linking, meaning that Java object references must be made at compile time, so that the compiler can implement strong type checking.
JavaScript uses dynamic linking, in which JavaScript object references are checked at run time and cannot be implemented without compilation

The check for the object reference.

7, JavaScript does not have the ability to read and write files and network control (its designers take into account the security factors and not provide support

Java provides these features, but JavaScript is the most convenient and efficient way to control and interact with Web content.

Of

Four, JavaScript program operating environment

Software Environment:
· Windows 95/98 or Windows NT.
· Netscape Navigator x.0 or Internet Explorer x.0.
• Character Editor (WS, WPS, Notepad, WordPad, etc.) or HTML document editor for editing HTML documents.

Hardware configuration:
You must first have a basic hardware configuration environment running Windows 95/98 or Windows NT. Recommended:
• Basic Memory 32M.
· CRT only needs 256 colors, resolution in 640x480 above.
· The CPU is only less than 233.
• Mouse and other external settings (as needed).

V. Writing the first JavaScript program

Let's use an example to write the first JavaScript program. It can explain how JavaScript scripts are embedded

into the HTML document.

Test1.html Documentation:

<script Language = "JavaScript" >
JavaScript appears here.
Alert ("This is the first JavaScript example!");
Alert ("Welcome you into the JavaScript world!");
Alert ("We will learn JavaScript together in the future!") ");
</Script>
</Head>
</Html>

Description

test.html is an HTML document whose identity format is the standard HTML format;
• Like the HTML identity language, the JavaScript program code is a text that can be browsed by word-processing software that describes the page

The HTML-related area appears.
· JavaScript code by <script Language = "javascript" >...</Script> description. In the identity <script

JavaScript scripts can be added between Language = "JavaScript" >...</Script>.
alert () is a JavaScript window object method whose function is to pop up a string that has an OK dialog box and displays ().
• Through <!--...//--> logo Description: If you do not know the JavaScript code of the browser, then all the identities in it are ignored

If you know it, execute the result. Using annotations This is a good programming habit that allows others to read your language.
· JavaScript ends with a </Script> tag.

From the above example analysis we can see that writing a JavaScript program is really very easy.

Top

JSP JS Java

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.