Deepu Assignment 3
Deepu Assignment 3
Deepu Assignment 3
Out : The Out object is a reference to an output stream that can be used within
scriptlets. In actual fact, the Out object represents the output stream of the JSP
page, the contents of which are being sent to a client browser.
The out object is the PrintWriter, which is used to send output to the client.
The out object has page scope and is and instance of javax.servlet.jsp.JspWriter
For Eg : out.print(“welcome to jsp”);
Response : The implicit Response object represents the response sent back to the
user browser as a result of processing the JSP page.
The response object has page scope. It encapsulates the response generated by the
JSP. This is the response being sent back to a client browser in response to its
request. The response is generated by the Web server and passed to the JSP as a
parameter to _jspService(). Here the response generated can be modified by the
JSP.
The response object is an instance of javax.servlet.http.HttpServletResponse.
1. Compilation of JSP page :- Here the generated java servlet file (test.java) is
compiled to a class file (test.class).
2. Instantiation :- Here an instance of the class is generated. The container
manages one or more instances by providing responses to requests.
3. Initialization :- jspInit() method is called only once during the life cycle
immediately after the generation of Servlet instance from JSP.
4. Request processing :- jspService() method is used to serve the raised
requests by JSP. It takes request and response objects as parameters. This method
cannot be overridden.
5. Destroy :- In order to remove the JSP from the use by the container or to
destroy the method for servlets, jspDestroy()method is used. This method is called
once, if you need to perform any cleanup task like closing open files, releasing
database connections, jspDestroy() can be overridden.
5. Explain JSP Elements in details.
Ans)The Elements are classified as follows:-
1. JSP Directives.
2. JSP Scripting Elements.
3. JSP Actions.
JSP Directives : In the web applications, JSP Directives can be used to define
present JSP page characteristics, to include the target resource content into the
present JSP page, and to make available user-defined tag library into the present
JSP page. All the JSP directives are going to be resolved at the time of translating
the JSP page to the servlet. The majority of JSP Directives will not give a direct
effect to response generation.
JSP Actions : In JSP applications, Scripting Elements are often wont to allow java
code inside JSP pages but the most theme of JSP technology isn’t to permit java
code inside the JSP pages. In the above context, to preserve the theme of JSP
technology we’ve to eliminate scripting elements from JSP pages, for this we’ve to
supply an alternate i.e. JSP Actions provided by JSP Technology. In the case of
JSP Actions, we’ll define the scripting tag in situ of java code, in JSP pages, and
that we will provide the respective java code inside the classes folder. In this
context, when the JSP container encounters the scripting tag then the container will
execute the respective java code and perform a specific action called JSP Action.
JSP Scripting Elements : In web applications, JSP Scripting Elements are often
wont to provide code in JSP pages. All the JSP Scripting Elements are going to be
resolved at the time of request processing. The majority of Scripting Elements will
give a direct effect on response generation. JSP scripting elements enable you to
insert java code directly into the servlet that will be generated from the current JSP
page. There are three types of Scripting Elements:
a. Declarations: Declaration of the form that is inserted into the body of the
servlet class, outside of any existing methods.
b. Scriptlets: Scriptlets of the form that are inserted into the servlets service
method.
c. Expressions: Expressions of the form that are evaluated and inserted into
out.
\ : It is used as a delimiter.