You are on page 1of 9

INTRODUCING TO JAVASCRIPT

JavaScript is the world's most popular programming language. A scripting language is a

lightweight programming language. JavaScript is programming code that can be inserted

into HTML pages. JavaScript inserted into HTML pages, can be executed by all modern web

browsers. JavaScript is easy to learn. JavaScript is the most popular scripting language on

the internet, and works in all major browsers, such as Internet Explorer, Firefox, Chrome,

Javascript is a dynamic computer programming language. It is lightweight and most

commonly used as a part of web pages, whose implementations Opera, and Safari.

JavaScript was designed to add interactivity to HTML pages before you start this lesson you

should already know HTML. It's important to understand the difference between Java and

JavaScript. Java is a full programming language developed by Sun Microsystems with

formal structures, etc. Most JavaScript must be written in the HTML document between

<SCRIPT> tags. You open with a <SCRIPT> tag, write your JavaScript, and write a closing

</SCRIPT> tag. allow client-side script to interact with the user and make dynamic pages. It

is an interpreted programming language with object-oriented capabilities.

JavaScript was first known as LiveScript, but Netscape changed its name to JavaScript,

possibly because of the excitement being generated by Java. JavaScript made its first

appearance in Netscape 2.0 in 1995 with the nameLiveScript. The general-purpose core of

the language has been embedded in Netscape, Internet Explorer, and other web browsers.

The ECMA-262 Specification defined a standard version of the core JavaScript language.

 JavaScript is a lightweight, interpreted programming language.

 Designed for creating network-centric applications.

 Complementary to and integrated with Java.

 Complementary to and integrated with HTML.


 Open and cross-platform

SERVLET:-

Servlets are most often used to [citation needed]. Process or store data that was submitted

from an HTML form Provide dynamic content such as the results of a database query.

Manage state information that does not exist in the stateless HTTP protocol, such as filling

the articles into the shopping cart of the appropriate customer. Technically speaking, a

"servlet" is a Java class in Java EE that conforms to the Java Servlet API, a standard for

implementing Java classes which respond to requests. Servlets could in principle

communicate over any client–server protocol, but they are most often used with the HTTP

protocol. Thus "servlet" is often used as shorthand for "HTTP servlet". Thus, a software

developer may use a servlet to add dynamic content to a web server using the Java platform.

To deploy and run a servlet, a web container must be used. A web container (also known as a

servlet container) is essentially the component of a web server that interacts with the servlets.

The web container is responsible for managing the lifecycle of servlets, mapping a URL to a

particular servlet and ensuring that the URL requester has the correct access rights. The

Servlet API, contained in the Java package hierarchy javax.servlet, defines the expected

interactions of the web container and a servlet. A Servlet is an object that receives a request
and generates a response based on that request. The basic Servlet package defines Java

objects to represent servlet requests and responses, as well as objects to reflect the servlet's

configuration parameters and execution environment. The package javax.servlet.http defines

HTTP-specific subclasses of the generic servlet elements, including session management

objects that track multiple requests and responses between the web server and a client.

Servlets may be packaged in a WAR file as a web application. Servlets can be generated

automatically from Java Server Pages (JSP) by the JavaServer Pages compiler. The difference

between servlets and JSP is that servlets typically embed HTML inside Java code, while JSPs

embed Java code in HTML. While the direct usage of servlets to generate HTML (as shown

in the example below) has become rare, the higher level MVC web framework in Java EE

(JSF) still explicitly uses the servlet technology for the low level request/response handling

via the Faces Servlet. A somewhat older usage is to use servlets in conjunction with JSPs in a

pattern called "Model 2", which is a flavor of the model–view–controller pattern. The current

version of Servlet is 3.1. Servlet can be described in many ways, depending on the context.

 Servlet is a technology i.e. used to create web application.

 Servlet is an API that provides many interfaces and classes including documentations.

 Servlet is an interface that must be implemented for creating any servlet.

 Servlet is a class that extend the capabilities of the servers and respond to the

incoming request. It can respond to any type of requests.

 Servlet is a web component that is deployed on the server to create dynamic web

page.
INTRODUCTION TO OPEN SOURCE:-

Open source describes practices in production and development that promote access to the end

product's source materials. Some consider open source a philosophy, others consider it a

pragmatic methodology. Before the term open source became widely adopted, developers and

producers used a variety of phrases to describe the concept; open source gained hold with the

rise of the Internet, and the attendant need for massive retooling of the computing source code.

Opening the source code enabled a self-enhancing diversity of production models,

communication paths, and interactive communities. Before the term open source became

widely adopted, developers and producers used a variety of phrases to describe the concept;

open source gained hold with the rise of the Internet, and the attendant need for massive

retooling of the computing source code. Opening the source code enabled a self-enhancing

diversity of production models, communication paths, and interactive communities.

CONNECTING TO SERVER
GLASSFISH:-GlassFish is an open-source application server project started by Sun

Microsystems for the Java EE platform and now sponsored by Oracle

e Corporation. The supported version is called Oracle GlassFish Server. GlassFish is free

software, dual-licensed under two free software licences: the Common Development and

Distribution License (CDDL) and the GNU General Public License (GPL) with the classpath

exception.

APACHE TOMCAT:-Apache Tomcat (or simply Tomcat, formerly also Jakarta Tomcat) is

an open source web server and servlet container developed by the Apache Software

Foundation (ASF). Tomcat implements the Java Servlet and the JavaServer Pages (JSP)

specifications from Sun Microsystems, and provides a "pure Java" HTTP web server

environment for Java code to run in. In the simplest config Tomcat runs in a single operating

system process. The process runs a Java virtual machine (JVM). Every single HTTP request

from a browser to Tomcat is processed in the Tomcat process in a separate thread

QUERYING THE DATABASE

Now that you have some data in the database, you probably want to retrieve it. You use the

SELECT statement to choose data that fits your criteria. Typical syntax for this command is

as follow:

SELECT [fieldnames]

AS [alias]

FROM [tablename]

WHERE [criteria]

ORDER BY [fieldname to sort on] [DESC]

LIMIT [offset, maxrows]

You can set numerous other parameters, but these are the most commonly used:
? SELECT [fieldnames]: First decide what specific fieldnames you want to retrieve; if you

want to see them all, you simply insert *.

? AS: You use the alias to group two or more fieldnames together so that you can reference

them later as one giant variable. An example would be:

SELECT first_name, last_name AS full_name. . . ORDER BY full_name . . .

You cannot use the AS parameter with the WHERE parameter, because this is a limitation of

MySQL.When the WHERE clause is executed, the column value may not be known.

? FROM: This is pretty self-explanatory: You just need to name the table or tables you are

pullingthe data from.

? WHERE: List your criteria for filtering out the data, as described in the following section.

? ORDER BY: Use this parameter if you want the data sorted on a particular field; if you

want theresults returned in descending order, add DESC.

? LIMIT: This enables you to limit the number of results returned and offset the first record

returned to whatever number you choose. An example would be: LIMIT 9, 10

This would show records 10 through 19. This is a useful feature for showing only a certain

number of records on a page, and then allowing the user to click a “next page” link to see

more.

WHERE: The beast clause called WHERE deserves its own little section because it’s really

the meat of the query.

Using PHP5 with MySQL

SELECT * FROM customers

//retrieves all information about all customers

SELECT * FROM customers WHERE gender = “Male”

//retrieves all information about male customers

Let’s look at the WHERE clause a little more in-depth:


? Comparison operators are the heart of the WHERE clause, and they include the following:

? =, <, >, <=, >=, !=

? LIKE and %: Oh how we like LIKE. LIKE lets you compare a piece of text or number and

gives you the % as a wildcard.

Example:

SELECT * FROM products WHERE description LIKE “%shirt%”

This gives you any records that have the word or text pattern of “shirt” in the description,

such as “t-shirt,” “blue shirts,” or “no shirts here.” Without the %s you would get only those

products that have a description of “shirt” and nothing else.

FORM

JAVA uses a set of simple yet powerful expressions that, once combined, provide you with

the means to do virtually anything you want. In this chapter, you begin to build a simple

application that allows you to add, edit, or delete members of a data set (in this instance,

movies, actors, and directors). This chapter welcomes you into a world of JAVA/MySQL

interaction by covering the following:

? Creating forms using buttons, text boxes, and other form elements

? Creating JSP scripts to process HTML forms

? Mastering $_POST and $_GET to retrieve data

? Passing hidden information to the form processing script via hidden form controls and a

URL query string

Working with Form


As a wise man once said, every journey starts with a single step. To start this particular

journey, you will focus on a very simple form. It will include only a text field and a submit

button in a table layout. The processing script will display only the value entered in the text

field. Try It Out Say My Name In this part, you are going to get JAVA to respond to a name

entered in a form. This is a simple variation of the typical “hello world” program, allowing

you to take your first step into interactivity. This is a simple variation of the typical “hello

world” program, allowing you to take your first step into interactivity.

<Form method=”POST” action=”java.jsp”><fieldset><legend>

Student Registration</legend><table border="0" cellspacing="8"

cellpadding="5"><tr><td>Student Id:</td<td><input type="number" required="required"

name="tid" value="" required="required"/></td>

</tr><tr><td>password:</td><td><input type="password" required="required"

name="tpassword" value="" required="required"/></td></tr><tr><input type="submit"

value="Register" name="btnRegister"/></tr>

</Form>

HOW IT WORKS

As with any recipe, it’s a good idea to start working on forms by understanding the

ingredients. To familiarize yourself with forms, you’ll need some background information

about HTML form elements and a few new JAVA functions. Let’s start with the HTML form

itself.

FORM ELEMENT

First, we’ll introduce the first HTML element you’ll need: FORM. It delimits the form area in

the page and holds the fields you want your Web site users to fill in.
<form action=”formprocess1.php” method=”post”>

<!--form controls here-->

</form>

Notice that the FORM element has an ending tag and two attributes. The first attribute

(action) is the recipient page address (the form processing script).

You might also like