jsp (java server page) is a server side program. is called by client to provide a web service. jsp...

10
Jsp (Java Server Page) Is a server side program. Is called by client to provide a web service. Jsp is written in HTML rather than with the java programming languge jspInt() - provides customized functionality when the jsp is called jspDestroy() - provides customized functionality when the jsp is destroyed Service – is automatically called & retrieves a connection to HTTP.

Upload: jonas-george

Post on 04-Jan-2016

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Jsp (Java Server Page) Is a server side program. Is called by client to provide a web service. Jsp is written in HTML rather than with the java programming

Jsp (Java Server Page)•Is a server side program.•Is called by client to provide a web service.•Jsp is written in HTML rather than with the java programming languge•jspInt() - provides customized functionality when the jsp is called •jspDestroy() - provides customized functionality when the jsp is destroyed•Service – is automatically called & retrieves a connection to HTTP.

Page 2: Jsp (Java Server Page) Is a server side program. Is called by client to provide a web service. Jsp is written in HTML rather than with the java programming

JSP TagsConsists of combination of HTML

tags & jsp tags.Jsp tags define java code that is

to be executed before the output of the jsp program is sent to the browser.

Tags begins with a <% …… %>Extended Markup Language(XML)

version of jsp tags <jsp:TagID>……</jsp:TagID>

Page 3: Jsp (Java Server Page) Is a server side program. Is called by client to provide a web service. Jsp is written in HTML rather than with the java programming

Processed by JSP Virtual machine. (TOMCAT)

Tomcat reads the jsp program whenever the program is called by a browser & sends the HTML tags , related information to the browser.

Page 4: Jsp (Java Server Page) Is a server side program. Is called by client to provide a web service. Jsp is written in HTML rather than with the java programming

JSP TagsComment tags : <% …….. %>Declaration tags : <%! …….. %>Directive tags : <%@ ……… %><%@ page import = import

java.sql.*;%>Expression tags : <%= ………..

%>Scriptlet TAGS : controls & loops

<%.....................%>

Page 5: Jsp (Java Server Page) Is a server side program. Is called by client to provide a web service. Jsp is written in HTML rather than with the java programming

Variables & Objects

<html><head><title> jsp </title></head><body><%! int age= 24;%><p> Your age is : <%=age%></body></html>

Page 6: Jsp (Java Server Page) Is a server side program. Is called by client to provide a web service. Jsp is written in HTML rather than with the java programming

Methods <html> <head> <title> jsp - methods</title> </head> <body> <%! int curve (int g) { return(10+g); } int curve1 (int a,int b) { return(a+b); } %> <p>Result : <%=curve(20)%> <p>Result1: <%=curve1(1,2)%> </body> </html>

Page 7: Jsp (Java Server Page) Is a server side program. Is called by client to provide a web service. Jsp is written in HTML rather than with the java programming

Control Statement<html><head><title> jsp - control</title></head><body>

<%! int g=60;%><% if(g>=70) { %><p> FIRST GRADE<% } else { %><p> SECOND GRADE</p><%}%>

</body></html>

Page 8: Jsp (Java Server Page) Is a server side program. Is called by client to provide a web service. Jsp is written in HTML rather than with the java programming

TOMCATJsp program executed by a JSP

Virtual machine.Tomcat is a JSP Virtual machine.

Page 9: Jsp (Java Server Page) Is a server side program. Is called by client to provide a web service. Jsp is written in HTML rather than with the java programming

Request StringThe browser generates a user request

whenever the submit button is selected.String s= request.getParameter(fname);String h[]=

request.getParameterValues(hobbies);

Is used to parse a value of a specified valueFour predefined implicit object request response session out – is an instance of the jspWriter that is used

to send a response to the client.

Page 10: Jsp (Java Server Page) Is a server side program. Is called by client to provide a web service. Jsp is written in HTML rather than with the java programming

Parsing Other InformationThe requested string send to the jsp by

the browser is divided into two general components that are separated by the question mark.

Left – url componentsRight – query stringMethos used to parse URL informationProtocol – http, https, ftpHost(ip address) Port Physical path