Scopes in JSP

In JSP you can create attributes in four scopes: page, request, session and application. If you need to access them Expression Language such as c:out tag, you can specify the scope explicitly.

Here are some examples:
<c:out value=”${pageScope.maxAttempts}” />
<c:out value=”${requestScope.maxAttempts}” />
<c:out value=”${sessionScope.maxAttempts}” />
<c:out value=”${applicationScope.maxAttempts}” />

If you try to display a value without specifying a scope, it first looks the value in the pageScope, requestScope, sessionScope and finally applicationScope. If it finds a value it displays otherwise it display ‘empty‘. Remember you won’t see null in the expression language.

Advertisements
This entry was posted in Uncategorized and tagged , . Bookmark the permalink.

One Response to Scopes in JSP

  1. Great content in your blog sir! Thank u very much for complimenting my post in http://karlapalem-hanumantharao.blogpost.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s