Thursday, 16 July 2015

JSP : Java Server Pages


JAVA SERVER PAGES



"JSP technology is an extension of the servlet technology."


JavaServer Pages (JSP) technology enables you to mix regular, static HTML with dynamically generated content from servlets. 
we write the regular HTML in the normal manner, then enclose the code for the dynamic parts in special tags, most of which start with <%and end with %>

HOW JSP WORKS

The process of making JavaServer Pages accessible on the Web is much simpler than that for servlets. all we need is a web server that support JSP pages . we save our file with .jsp extension and thats all no compiling, no packages, no classpath required.
Behind the scene our JSP page is translated into a servlet where static HTML content being printed to the output stream associated  with servlet's service method.

Inside a JSP Page :

Aside from the regular HTML, there are three main types of JSP constructs that you embed in a page: scripting elements, directives, and actions.

SCRIPTING ELEMENTS :   java code that will become part of                                                      resultant servlet.
DIRECTIVES :    control the overall structure of servlet.

ACTION :    control the behaviour of JSP engine.

SCRIPTING ELEMENTS 

  1.  EXPRESSIONS :  which are evaluated and then inserted into servlet's output .                                                                                                           General form :   <%=           %>                                                                      Alternate XML syntax :                                                                                                                                                              <jsp : expression>                                                                        Java Expression                                                                         </jsp : expression>                                                                      
  2. SCRIPTLETS :  which are inserted into servlet's  _service method.                                                                                                   General form:    <%               %>                                               Alternate XML syntax :                                                                                                     <jsp : scriptlets>                                                                             code                                                                                          </jsp : scriptlets>                                                                          
  3. DECLARATION : which are inserted into body of servlet's class outside any method.                                                                         General form:     <%!       %>                                             Alternate XML syntax :                                                                                                     <jsp : declaration>                                                                         code                                                                                         </jsp : declaration>

Static HTML inside a JSP page is called Template Text.

JSP Comments are in the form   <%--   jsp comment        --%> 

A simplest example of 

EXAMPLE :   

ScriptingElement.jsp 

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<html>
<head>
<title>Insert title here</title>
</head>

<body>

<%--   expression example     --%>
current date and time is :
<%=   new java.util.Date()    %>
<hr>
<%= request.getRemoteHost() %>
<hr>

<%--   delaration example     --%>
<%!   int count =1;    %>

<%--    scriptlet example     --%>
<%      count++;
       out.println(count);   %>
<hr>
</body>
</html>


OUTPUT



Thursday, 8 May 2014

ARRAY  IN  DATA STRUCTURE





There are 2 type of implementations of Ordered List data structure :     
                                                                     1.     Array
                                                                     2     Pointer
  •  Ordered list structures that are implemented with arrays are known as Sequential List.
  • Arrays are collection of elements where each element is identified by an index or key.
  • Memory Address of the first element of the array is called Base Address.
  • Two dimensional arrays are also called :    Tables Array   or Matrix Array.
  • especially Vector Processors are often optimized for array operations.
  • Arrays can be used to determine partial or complete control flow of program so also known as Control Tables.
  • Array indices (subscript)  may begin with 0,1,n. and other data types like enumeration or characters may be used as array index.
  • The number of indices needed to specify an element is called Dimension  or Rank of the array. 
  • Address Formula for the element at index i 
        :  for one dimensional array = B+C.i         
                                                             where B= Base address
                                                      C= constant (add increment)

       :  for two dimensional array   B+C.i+d.j
  • Dope Vector or Array's descriptor or Stride Vector 
Dope Vector is a record that include all the parameters as dimension d, base add. b, and the increment c1,c2 ....ck.





Search This Blog

Total Pageviews