Name Interface Tomcat Implementation
pageContext javax.servlet.jsp.PageContext org.apache.jasper.runtime.PageContextImpl

JSP implicit object pageContext example program (github)

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<!-- jsp implicit object pageContext example -->

<!-- how to set attribute into jsp implicit object pageContext -->
<% pageContext.setAttribute("attribute1", "attribute1Value"); %>
<!-- how to get attribute from pageContext -->
pageContext parameter : <% out.println(pageContext.getAttribute("attribute1")); %> <br/>
<!-- how to access request parameter using jsp implicit object pageContext -->
Request parameter who : <% out.println(pageContext.getRequest().getParameter("who")); %> <br/>
<!-- how to access session object using jsp implicit object pageContext -->
Session id : <% out.println(pageContext.getSession().getId()); %>


How to run the JSP page context sample program


Leave a comment

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