Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSI 3125, Preliminaries, page 1 JSP (Java Server Pages)

Similar presentations


Presentation on theme: "CSI 3125, Preliminaries, page 1 JSP (Java Server Pages)"— Presentation transcript:

1 CSI 3125, Preliminaries, page 1 JSP (Java Server Pages)

2 CSI 3125, Preliminaries, page 2 JSP (Java Server Pages) JavaServer Pages (JSP) is a server-side programming technology that enables the creation of dynamic, platform-independent method for building Web-based applications. JSP have access to the entire family of Java APIs, including the JDBC API

3 CSI 3125, Preliminaries, page 3 JSP (Java Server Pages) Html+java=jsp In servlet need 3 file html, web.xtml,java Next technology of servlet is jsp Inserted of 3 file in servlet  jsp with 1file JSp ->.jsp extension Executed on the webserver apache tomcat, web logic, sphere… Used for UI/front end/ display purpose (multipurpose)

4 CSI 3125, Preliminaries, page 4 JSP (Java Server Pages) JSP execution Procedure When JSP compile (using JSP compiler)--> converted to servlet file Servlet file is compiled and generate. class file This class file is loaded into memory and executed by JVM

5 CSI 3125, Preliminaries, page 5 JSP (Java Server Pages) JSP LIFE CYCLE Same as Servlet life cycle init(), service(), destroy(); JSP has JspInit() - is called when JSP is loaded in memory jspService(); - is called when the client request jspDestroy(); - invoked when JSP is removed from memory not need to write these methods they automatically run

6 CSI 3125, Preliminaries, page 6 JSP (Java Server Pages) There are five types of JSP tags: Directive tag Comment Tag Expression tag Declaration statement tag Scriplet tag

7 CSI 3125, Preliminaries, page 7 JSP (Java Server Pages) DIRECTIVES To perform a specific task They have the general form: There are diff standard directives page include

8 CSI 3125, Preliminaries, page 8 JSP (Java Server Pages) DIRECTIVES Tag The page Directive The page directive apply different properties for the page syntax: Following are names of some of important the attributes of the page directive used in JSP import: : This attribute imports the java packages and it's classes. Eg: contentType: This attribute specifies the type i.e. used for the JSP response Eg:

9 CSI 3125, Preliminaries, page 9 JSP (Java Server Pages) DIRECTIVES Tag The include directive The include directive merges the contents of another file like a #include C preprocessor directive. The syntax is where filename can specify with path. Eg:

10 CSI 3125, Preliminaries, page 10 JSP (Java Server Pages) Comment Tag Expression tag The expression can have any data value Eg:

11 CSI 3125, Preliminaries, page 11 JSP (Java Server Pages) Declaration statement tag Declare variables and functions Eg: <%! private int example = 0 ; private int test = 5 ; %> SCRIPTLETS A scriptlet consists of one or more valid Java statements Ie java code Eg:

12 CSI 3125, Preliminaries, page 12 JSP (prog) <%! int a=10; int b=20;%>

13 CSI 3125, Preliminaries, page 13 JSP ( Method def and calling prog) <%! int add(int x,int y) { return (x+y);} %> Calling Method

14 CSI 3125, Preliminaries, page 14 JSP (Java Server Pages)


Download ppt "CSI 3125, Preliminaries, page 1 JSP (Java Server Pages)"

Similar presentations


Ads by Google