{"id":83,"date":"2009-09-02T21:35:38","date_gmt":"2009-09-02T21:35:38","guid":{"rendered":"http:\/\/localhost\/tfcom_wp\/2009\/09\/02\/request-session-jstl\/"},"modified":"2009-09-02T21:35:38","modified_gmt":"2009-09-02T21:35:38","slug":"request-session-jstl","status":"publish","type":"post","link":"https:\/\/www.tech-freaks.com\/java\/code-snippets\/request-session-jstl.html","title":{"rendered":"Accessing Request\/session attributes using JSTL"},"content":{"rendered":"<div style=\"text-align: left;\">JSTL and EL together provide an easy way to access session, request and application scope variables. EL provides implicit variables like sessionScope, requestScope, applicationScope and many more which are actually Map type. They can be navigated easily by using dot operator to access any attributes added to it.<\/div>\n<div style=\"text-align: left;\">\u00a0<\/div>\n<div style=\"text-align: left;\">Below JSP code provides a simple way of accessing and displaying the values.<\/div>\n<div style=\"text-align: left;\">\u00a0<\/div>\n<div style=\"text-align: left;\">Note that we have added the scriptlet in the page, just to show that we are adding value in session and request variables. Scriptlets should be avoided when JSTL and EL are used.<\/div>\n<div style=\"text-align: left;\">\n<pre class=\"language-markup\"><code>&lt;%@ taglib uri=\"http:\/\/java.sun.com\/jstl\/core\" prefix=\"c\" %&gt;\r\n \r\n&lt;%  \/\/Scriptlets are not to be used\r\n request.setAttribute(\"param1\", \"Hello JSTL World!\");\r\n session.setAttribute(\"userName\", \"Generic User\");\r\n%&gt;\r\n\r\nHello &lt;c:out value=\"${sessionScope.userName}\"\/&gt;,&lt;\/p&gt;\r\nWelcome to &lt;c:out value=\"${requestScope.param1}\"\/&gt;&lt;\/p&gt;<\/code><\/pre>\n<p>\u00a0<\/p><\/div>\n<div style=\"text-align: left;\">It provides a output as below:<\/div>\n<div style=\"text-align: left;\">\u00a0<\/div>\n<div style=\"text-align: left;\"><em>Hello Generic User,<\/em><\/div>\n<div style=\"text-align: left;\"><em>Welcome to Hello JSTL World!<\/em><\/div>\n","protected":false},"excerpt":{"rendered":"<p>JSTL and EL together provide an easy way to access session, request and application scope variables. EL provides implicit variables [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[13],"tags":[],"class_list":["post-83","post","type-post","status-publish","format-standard","hentry","category-code-snippets"],"_links":{"self":[{"href":"https:\/\/www.tech-freaks.com\/wp-json\/wp\/v2\/posts\/83","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tech-freaks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tech-freaks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tech-freaks.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tech-freaks.com\/wp-json\/wp\/v2\/comments?post=83"}],"version-history":[{"count":0,"href":"https:\/\/www.tech-freaks.com\/wp-json\/wp\/v2\/posts\/83\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tech-freaks.com\/wp-json\/wp\/v2\/media?parent=83"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tech-freaks.com\/wp-json\/wp\/v2\/categories?post=83"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tech-freaks.com\/wp-json\/wp\/v2\/tags?post=83"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}