During the translation phase, the jsp engine declares and initializes nine commonly used variables in the service method of the generated servlet. They are implicitly made available to a jsp without need of declaring them. These are known as implicit variables or implicit objects. They are as follows.

o   Request
o   Response
o   Session
o   Config
o   Application
o   Page
o   Exception
o   Out
o   pageContext

Request:- This object is of type javax.Servlet.http.HttpServletREquest. It refers to the current request to the jsp. By using this object we can capture the client data. For example in a scriptlet we can write as follows.

<%
            String name=request.getParameter(“html textbox name”);
%>

With the above scriptlet we can get the form data directly into the jsp.

Response:- This objet is of type javax.servlet.http.HttpServletResponse. It  is used for sending customized response to the client.

Session:- This object is of type javax.servlet.http.HttpSession. This object is not available in a jsp if we  say <%@ page session=”false” %>. In a servlet when we available in a jsp it is imlicitly available. If we want to implement session tracking in a jsp, we make use of this object.

Config:- The object is of type javax.servlet.ServletConfig. When initialization parameters are supplied to the jsp explicitly from the web.xml. we can retrieve them by using this object.
<% String paramvalue=config.getInitParameter(“Paramname”); %>

Application:- This is an object of type javax.servlet.ServletContext. It refers to the environment to which the jsp belongs. Using this object we can retrieve application level state. All the web components(Jsps & servlets) running in the same application can share common information. For example if a servlet or another jsp has stored some info in the ServletContext object, in our current jsp we can retrieve it as follows.

<%  String value=(String)application.getAttribute(“name”); %>

Page:- The is an object of type java.lang.object. It refers to the instance of the generated servlet. This is very rarely used in a jsp.

Exception:- This object


Post a Comment

Unknown said... April 28, 2017 at 12:56 AM


Given so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more ... good luck. java training institutes in chennai | java j2ee training institutes in velachery

 
Top