jsp (java server page) is a server side program. is called by client to provide a web service. jsp...
TRANSCRIPT
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.
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>
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.
JSP TagsComment tags : <% …….. %>Declaration tags : <%! …….. %>Directive tags : <%@ ……… %><%@ page import = import
java.sql.*;%>Expression tags : <%= ………..
%>Scriptlet TAGS : controls & loops
<%.....................%>
Variables & Objects
<html><head><title> jsp </title></head><body><%! int age= 24;%><p> Your age is : <%=age%></body></html>
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>
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>
TOMCATJsp program executed by a JSP
Virtual machine.Tomcat is a JSP Virtual machine.
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.
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