Jsp is a Web Technology Function

28
JSP Jsp is a web technology function which is used to develop server side web components. Jsp will be used in presentation layer. Complete jsp life cycle will be taken care by web container. Jsp page is combination of HTML elements and JSP elements. Following is the list of JSP elements: ---------- 1. Scripting elements Scriplets Expressions Declarations 2. Directives Page directives Include directives taglib directives 3. Standard elements <jsp:include> <jsp:forward> <jsp:param> <jsp:useBean> <jsp:setProperty> <jsp:getProperty> 4. Custom elements(Tags) Syntax: ---------- <% ---- ---- ---- ---- ---- %> Scriplets is used to write any valid java statement. All the elements inside the Scriplets must be terminated by semicolon. Example: -------- <% int a=10; out println(a); // Implicit object %> All the statements inside the Scriplets will be placed inside the service() method of translated servlet. Scripting Elements Expression

description

jsp

Transcript of Jsp is a Web Technology Function

JSP Jsp is a web technology function which is used to develop server side web components. Jsp will be used in presentation layer. Complete jsp life cycle will be taken care by web container. Jsp page is combination of HTML elements and J! elements."ollowing is the list of J! elements# $$$$$$$$$$1. Scripting elements criplets %&pressions 'eclarations2. Directives !age directives (nclude directives taglib directives3. Standard elements )jsp#include* )jsp#forward* )jsp#param* )jsp#use+ean* )jsp#set!roperty* )jsp#get!roperty*,. Custom elements-Tags.Syntax: ----------)/$$$$ $$$$$$$$$$$$ $$$$/* criplets is used to write any valid java statement. 0ll the elements inside the criplets must be terminated by semicolon. %&ample# $$$$$$$$)/ int a1234out println-a.455 (mplicit object/* 0ll the statements inside the criplets will be placed inside the service-. method of translated servlet.Syntax# $$$$$$$$$$$$$$$$$$)/1e&p /*%&p#$$$$$)/16sri6/*)/1a/*)/1obj.m2-.4/* 7-invalid. %&pression is a short$cut form of out.println. Scripting ElementsExpression 0ll the e&pression inside the J!8s will be placed inside the service-. method of translated servlet .ynta$$$$$$$$$$)/ 9$$$$$$$$$$$ $$$$$ $$$$$$$$$ /* (t is used to write variable declaration and method definition. Java statement are not allowed inside the declaration all the declaration inside the J! will be placed directly inside the translated servlet class and outside the service-. method.%&p# $$$$$$$$$$)/ 9 :oid m2-.;ystem.out.println-4:oid m2-.;ystem.out.println-&.4ystem.out.println->P scope1PsessionP5*)sd#set name1PsnameP value1PsriP5*)br*id#)sd#out name1PsidP scope1PsessionP5*)br*name#)sd#out name1PsnameP scope1PreAuestP5*)sd#remove name1PsnameP5*)sd#remove name1PsidP5*)br*id#)sd#out name1PsidP scope1PsessionP5*)br*name#)sd#out name1PsnameP5*package com.jlc4public class JspNtil;public static boolean is%mpty-tring str.;if-str11nullVVstr.length-.113.;return true4=return false4==4et&odo$ JSPThere are ten %L implement object# $$$$$$$$$$$$$ !ageConte&t !arent:alue Header Header:alue !aram Cookie pagecope reAuestcope sessioncope applicationcope Catch tag#$$$$$$$$$Catch tag is used to finding the e&ception inside the jsp without writing try O catch block inside the criplets.%&ample(mplement the following custom tagsSet tag# $$$$$$$ 0ttribute#$$ nameB valueB scopeNote #$$$$ name BvalueB attribute are mandatory and scope is optional. if scope is not specifyB then the default scope is page.3emove tag: ---------- 0ttribute#$$ nameB scope.Note #$$$$$$$ name is mandatory and scope is optional. Ghen scope is not specifiedB it has to verify in all the scopes