JSP Built in Objects with Examples




Hey guys in this article, you will learn about JSP built in objects with easy to understand examples.

Read More:

Overview


Following are the most commonly used JSP built in server objects

Object Description
request Contains HTTP request headers and form data
response  Provides HTTP support for sending response
out JspWriter for including content in HTML page
session Unique session for each user of the web application
application Shared data for all users of the web application

Complete Example


Follow the below steps to understand the complete example

Create a Project


You can check the following post to create a new Dynamic Web Project

Create a JSP file


Create JSPObjects.jsp file under WebContent and add the following content

<%@page import="in.bushansirgur.Test"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>

	<p>Request object example: <%= request.getHeader("User-agent") %> </p>
	
	<p>Session object example: <%= session.getLastAccessedTime() %> </p>
	
</body>
</html>

Run the file


Right click on the File, choose Run As, choose Run on Server. It will open in a default web browser, you will see the following content
00-12

That’s it for this post, if you like this post, please share this post with your friends and collogues and also share this on your social media profiles.



Bushan Sirgur

Hey guys, I am Bushan Sirgur from Banglore, India. Currently, I am working as an Associate project in an IT company.

Leave a Reply