Starter Tutorials Blog
Tutorials and articles related to programming, computer science, technology and others.
Subscribe to Startertutorials.com's YouTube channel for different tutorial and lecture videos.
Home » Programming » Advanced Java » JSP » Create a JSP page to request implicit object
Suryateja Pericherla Categories: JSP. No Comments on Create a JSP page to request implicit object
Join Our Newsletter - Tips, Contests and Other Updates
Email
Name

Aim

Create a JSP page to request implicit object.

 

Theory

There are 9 JSP implicit objects. These objects are created by the web container that are available to all the jsp pages.

 

The available implicit objects are as given below:

Object Type
out JSPWriter
request HttpServletRequest
response HttpServletResponse
config ServletConfig
application ServletContext
session HttpSession
pageContext PageContext
page Object
exception Throwable

 

out Object

For writing any data to the buffer, JSP provides an implicit object named out. It is the object of JspWriter.

<% out.print("Today is:"+java.util.Calendar.getInstance().getTime()); %>

 

request Object

The JSP request is an implicit object of type HttpServletRequest i.e. created for each jsp request by the web container. It can be used to get request information such as parameter, header information, remote address, server name, server port, content type, character encoding etc.

<%   
String name=request.getParameter("uname");  
out.print("welcome "+name);  
%>

 

response Object

In JSP, response is an implicit object of type HttpServletResponse. The instance of HttpServletResponse is created by the web container for each jsp request. It can be used to add or manipulate response such as redirect response to another resource, send error etc.

<% response.sendRedirect("https://www.andhrauniversity.edu.in");  %>

 

config Object

In JSP, config is an implicit object of type ServletConfig. This object can be used to get initialization parameter for a particular JSP page. The config object is created by the web container for each jsp page.

<%   
String name = config.getInitParameter("uname"); 
%>

 

application Object

In JSP, application is an implicit object of type ServletContext. The instance of ServletContext is created only once by the web container when application or project is deployed on the server.

 

This object can be used to get initialization parameter from configuaration file (web.xml). It can also be used to get, set or remove attribute from the application scope.

<%  
String name = application.getInitParameter("uname");   
%>  

 

session Object

In JSP, session is an implicit object of type HttpSession.The Java developer can use this object to set, get or remove attribute or to get session information.

<%
session.setAttribute("user",name);  
%>

 

Program

index.jsp

<html>
<head>
<title>Welcome</title>
</head>
<body>
	<% out.print("Printed using the out implicit object."); %>
</body>
</html>

 

Input and Output

index.jsp

JSP implicit object

 

How useful was this post?

Click on a star to rate it!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Leave a Reply

Your email address will not be published. Required fields are marked *

Facebook
Twitter
Pinterest
Youtube
Instagram
Blogarama - Blog Directory