Presentation is loading. Please wait.

Presentation is loading. Please wait.

World Wide Web has been created to share the text document across the world. In static web pages the requesting user has no ability to interact with the.

Similar presentations


Presentation on theme: "World Wide Web has been created to share the text document across the world. In static web pages the requesting user has no ability to interact with the."— Presentation transcript:

1 World Wide Web has been created to share the text document across the world. In static web pages the requesting user has no ability to interact with the content delivered by the web server. The term dynamic describes the process of generating HTML pages according to the information requested by the user to the web server.

2 Client Side Scripting Scripting means the location where the code is processed. In CSS code is processed at the client side. We embed client side scripting languages code to the HTML. E.g. Javascript,Vbscript,Jscript

3 Advantages 1.Work on the server is reduced, since processing is done at client side. 2.Network traffic is reduced. 3.Faster than server side scripting.

4 Disadvantages 1.Code is completely visible to the user and hence no security to data.

5 Server Side Scripting Request is processed at the server side. Coder is protected. Server will have additional workload. Comparatively slow. E.g. CGI/Perl, JSP,ASP

6 The problem with CGI is that program must be restarted for every request. Sun Microsystems introduced servlet to solve this problem. Servlet is a small piece of code that extends the functionality of a server. Later JSP was introduced.

7 Phases of a JSP Each JSP goes through 2 distinct phases. 1.Translation phase/time 2.Request phase/time At translation phase JSP engine turns JSP file into a servlet. It happens whenever we modify a JSP file. At Request phase servlet is run to generate the required page. Handling of comments happens at translation phase.

8 JSP Processing The following steps explain how the web server creates the web page using JSP: As with a normal page, your browser sends an HTTP request to the web server. The web server recognizes that the HTTP request is for a JSP page and forwards it to a JSP engine. This is done by using the URL or JSP page which ends with.jsp instead of.html.

9 The JSP engine loads the JSP page from disk and converts it into a servlet content. This conversion is very simple in which all template text is converted to println( ) statements and all JSP elements are converted to Java code that implements the corresponding dynamic behavior of the page.

10 The JSP engine compiles the servlet into an executable class and forwards the original request to a servlet engine. A part of the web server called the servlet engine loads the Servlet class and executes it. During execution, the servlet produces an output in HTML format, which the servlet engine passes to the web server inside an HTTP response.

11 The web server forwards the HTTP response to your browser in terms of static HTML content. Finally web browser handles the dynamically generated HTML page inside the HTTP response exactly as if it were a static page.

12

13 In order to execute a jsp page we have 2 requirements. 1.Java should be installed. 2.Webserver should be installed. E.g. Tomcat,Weblogic,Websphere

14 Building blocks of JSP 1.JSP expressions 2.JSP scriplets 3.JSP declarations

15 JSP expression It has the following form It is used to insert java values directly into the output. Java expression is evaluated, converted to a string and inserted in the page.

16 A Comment Test Today's date:

17 Output Today's date: 05-Sep-2012 10:24:25

18 JSP Comments JSP comment marks text or statements that the JSP container should ignore. A JSP comment is useful when you want to hide or "comment out" part of your JSP page. Following is the syntax of JSP comments:

19 JSP declarations It takes the form E.g. The browser will display 101. JSP declaration can contain many declarations but a JSP expression contains only one expression.

20 We can also declare a method in a JSP declaration and can call it from a JSP expression. <%! int count=100; int plusone(int n) { return n+1; } %> The no: you are looking is The no: is still

21 Scriplets It is a piece of Java code sandwiched between the characters It takes the following form:

22 Have a nice day! Have a dull day!

23 Hello World Hello World!

24 DeclarationScripletExpression Enclosed in ContainsOne or more java declarations or method definitions Java code(condition checking,loops etc) One java expression What it doesCreates a name possibly gives the name a value Tells the system to do something Has a value When the JSP container runs it When page is 1 st visited or the JSP container reinitializes the page Whenever someone visits the page

25 Request and Response Objects When we receive a request from a user, we can get information about that request by calling methods associated with the implicit request object. When you prepare a response, we can set the characteristics of the response b calling methods associated with the implicit response object.

26 Methods of request object are: 1.getHeader() (i)Browser your are using is (ii)Cookie information stored is (iii)Your browser is willing to accept the following MIME types

27 2. getMethod() (i) Method used for sending request is 3.getRemoteAddr() (i) IP address of the client machine is 4.getRemoteHost() (i) DNS name is

28 5. getLocale() (i)You are from (ii)You are using language.

29 Methods of remote object are: 1.sendRedirect() 2.sendError()

30 Forms and request parameters Login.htm validation Username Password

31 Clicking the Submit button send the following request: http://www.abc.com/authenticate.jsp?username=a bc & password=xyz

32 authenticate.jsp <% If(request.getParameter(“pwd”).equals (“xyz”)){ %> Welcome <% } else { %>


Download ppt "World Wide Web has been created to share the text document across the world. In static web pages the requesting user has no ability to interact with the."

Similar presentations


Ads by Google