12
var arrayname = new Array(size);
Where
var, new - keyword
arrayname - user defined name
size - size of the array
Assigning values to the created array
This is use to giving initial values to the created array is called assigning values.
Syntax
arrayname(index) =‖value‖;
Example
var fruits = new array( "banana", "orange", "grapes" );
Methods in array object
i) length() – this method is used to find the number of elements in an array
ii) concat()-Returns a new array comprised of this array joined with other array(s).
iii)filter() - Creates a new array with all of the elements of this array for which the
provided filtering function returns true.
iv) join()-Joins all elements of an array into a string.
v) foreach()-Calls a function for each element in an array.
vi) reverse() – It is used to reverse the order of elements in an array.
vii) shift() - Removes the first element from an array and returns that element.
viii) sort()-Sorts the elements of an array
20.(a) What are the implicit objects? Explain request and session object[10]
Implicit Objects
Implicit objects created by the web container. These objects are used to create JSP pages. The users
need not to declare these objects, but they are provided by the container in the implementation class.
All the implicit objects are available only to scriplets and expressions only. The following are the
implicit objects.
Request Object
Response Object
Page context Object
Session Object
Application Object
Out Object
Page Object
Config Object
Exception Object
Request Object
The request object is an instance of a javax.servlet.http.HttpServletRequest object. Each time a
client requests a page the JSP engine creates a new object to represent that request.
The request object provides methods to get HTTP header information including form data, cookies,
HTTP methods etc.
Session object
A session is defined as a series of related interaction between a single client and the server. A
session object is created on the server. It is an unique identifier and is called session id. This id is given to
the client for communicating with the server. If the user is accessing a site having more than one JSP or
servlet pages, the same session id is shared among all the page.
20.(b).(i) Explain the JSP architecture.[5]
The web server needs a JSP engine ie. container to process JSP pages. The JSP container is
responsible for intercepting requests for JSP pages.