Introduction To Java Scripts
Introduction To Java Scripts
Now that we’ve gotten a bird’s-eye view of JavaScript, let’s get into the more technical detail. JavaScript
was created to add ‘life to webpages’. Just like HTML and CSS, JavaScript is written in plain text files with
a .js extension.
As previously mentioned, JavaScript can be used to accomplish many useful operations on the frontend,
like validating forms, alerting users, storing temporary data, and performing calculations—to name just a
few.
Apart from the name itself, JavaScript has no relation to Java. Beginners often get confused ip: between
the two languages. Remember that Java is an entirely different language made for a different purpose
(although you’ll still find it running on certain website backends).
Lastly, before we look at today’s itinerary, remember that JavaScript, just like HTML and CSS (but maybe
even more so), is a vast language. We’ll only be learning parts of it that are relevant to us today, so we’ll
list some good resources at the end if you’d like to learn more.
JavaScript is template based not class based. Here, we don't create class to get the object. But, we direct
create objects.
A DTD can be declared inside an XML document as inline or as an external recommendation. DTD
determines how many times a node should appear, and how their child nodes are ordered.
XML Schemas,
An XML schema is a description of a type of XML document, typically expressed in terms of constraints
on the structure and content of documents of that type, above and beyond the basic syntactical
constraints imposed by XML itself. These constraints are generally expressed using some combination of
grammatical rules governing the order of elements, Boolean predicates that the content must satisfy,
data types governing the content of elements and attributes, and more specialized rules such as
uniqueness and referential integrity constraints.
The DOM represents a document with a logical tree. Each branch of the tree ends in a node, and each
node contains objects. DOM methods allow programmatic access to the tree. With them, you can
change the document's structure, style, or content.
Presenting XML
Presenting XML is a Java web application framework for presenting HTML, PDF, WML etc. in a device
independent manner. It aims to achieve a complete separation of content and presentation. It supports
various kinds of content including XML files, dynamic content, SQL result sets and flat files. It provides a
declarative way for applying filters and XSLT transforms to a stream of XML content in a pipeline. It
allows user defined filters and serializers written as Java plug-ins. It is component based and extendible.
Presenting XML may be used as a command line tool or as a framework for a servlet-based web
application. Simple examples with XML, XSLT, and Java are included in the distribution. There are
command line examples for converting flat files to XML (and vice versa), for converting SQL results to
XML, for applying a sequence of XSLT transforms and SAX filters in a pipeline, and for setting up
streaming filters.
REVIEW OF APPLETS:
Applets are small applications that are accessed on an Internet server, transported over the
After an applet arrives on the client, it has limited access to resources, so that it can produce an
arbitrary multimedia user interface and run complex computations without introducing the risk of
viruses or breaching data integrity.
APPLET CLASS:
The Applet class is contained in the java.applet package. Applet contains several methods that
give you detailed control over the execution of your applet. All applets are subclasses of Applet. Thus, all
applets must import java.applet. Applets must also import java.awt. Since all applets run in a window, it
is necessary to include support for that window. Applets are not executed by the console-based Java
run-time interpreter. Rather, they are executed by either a Web browser or an applet viewer.
Execution of an applet does not begin at main( ). Actually, few applets even have main( )
methods. Instead, execution of an applet is started and controlled with an entirely different mechanism.
Output to your applet’s window is not performed by System.out.println( ). Rather, it is handled with
various AWT methods, such as drawString( ), which outputs a string to a specified X,Y location. Input is
Once an applet has been compiled, it is included in an HTML file using the APPLET tag. The applet
will be executed by a Java-enabled web browser when it encounters the APPLET tag within the HTML
file. To view and test an applet more conveniently, simply include a comment at the head of your Java
source code file that contains the APPLET tag. This way, your code is documented with the necessary
HTML statements needed by your applet, and you can test the compiled applet by starting the applet
viewer with your Java source code file specified as the target. Here is an example of such a comment:
/*
</applet>
*/
This comment contains an APPLET tag that will run an applet called MyApplet in a window that is
EVENT HANDLING:
As Applets are event-driven programs, event handling is at the core of successful applet
programming. Most events to which your applet will respond are generated by the user. These events
are passed to your applet in a variety of ways, with the specific method depending upon the actual
event. There are several types of events. The most commonly handled events are those generated by
the mouse, the keyboard, and various controls, such as a push button. Events are supported by the
java.awt.event package.
The modern approach to handling events is based on the delegation event model, which defines
standard and consistent mechanisms to generate and process events. Its concept is quite simple: a
source generates an event and sends it to one or more listeners. In this scheme, the listener simply waits
until it receives an event. Once received, the listener processes the event and then returns. The
advantage of this design is that the application logic that processes events is cleanly separated from the
user interface logic that generates those events. A user interface element is able to “delegate” the
In the delegation event model, listeners must register with a source in order to receive an event
notification. This provides an important benefit: notifications are sent only to listeners that want to
receive them. This is a more efficient way to handle events than the design used by the old Java 1.0
approach.
AWT PROGRAMMING:
The AWT contains numerous classes and methods that allow you to create and manage
windows. Although the main purpose of the AWT is to support applet windows, it can also be used to