Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 15

JSP Processing

by

CH.JAYANTH
 JSP stands for Java Server Pages. All your JSP
pages are stored on the server.
 The web server have JSP engine which acts as a
container to process JSP pages.
 All the requests for JSP Pages are intercepted
by JSP Container.
 JSP container along with web server provide
the runtime environment to JSP.
JSP Processing Architecture
steps that are required to process JSP Page –

 Web browser sends an HTTP request to the web


server requesting JSP page.
 Web server recognizes that the HTTP request by
web browser is for JSP page by checking the
extension of the file (i.e .jsp)
 Web server forwards HTTP Request to JSP engine.
 JSP engine loads the JSP page from disk and
converts it into a servlet
 JSP engine then compiles the servlet into an
executable class and forward original request to a
servlet engine.
 Servlet engine loads and executes the Servlet
class.
 Servlet produces an output in HTML format
 Output produced by servlet engine is then passes
to the web server inside an HTTP response.
 Web server sends the HTTP response to
Web browser in the form of static HTML
content.
 Web browser loads the static page into the
browser and thus user can view the
dynamically generated page.
Variable Declaration
JSP Declaration
 A declaration tag is a piece of Java code for declaring
variables, methods and classes. If we declare a variable
or method inside declaration tag it means that the
declaration is made inside the servlet class but outside
the service method.

 We can declare a static member, an instance variable


(can declare a number or string) and methods inside
the declaration tag.
Syntax of declaration tag:

<%! Declaration %>


Example 1: Variables declaration
In this example we have declared two variables inside declaration
tag <html>
<head>
<title>Declaration tag Example1</title>
</head>
<body>
<%! String name="Chaitanya"; %>
<%! int age=27; %>
<%= "Name is: "+ name %><br>
<%= "AGE: "+ age %>
</body>
</html>
Output :-
Example 2:
Methods declaration
In this example we have declared a method sum using
JSP declaration tag.
<html>
<head>
<title>Methods Declaration</title>
</head>
<body>
<%!
int sum(int num1, int num2, int
num3){
return num1+num2+num3;
}
%>

<%= "Result is: " + sum(10,40,50)


%>
</body>
</html>
Output :-
Thank
You

You might also like