Akash
Akash

Reputation: 5012

Access JSP page objects in EL tags

I have a code like

<% int myvar =20; %>

I wish to access it via JSP tags, is something like this possible?

${pageScope.myvar}

Upvotes: 1

Views: 76

Answers (2)

KV Prajapati
KV Prajapati

Reputation: 94645

Scriptlet variables are created in service method and hence they have local scope so the

EL cannot evaluate them. The EL operates upon scoped variables - page scope, request,

session and application scope.

Upvotes: 1

Niroshan Abayakoon
Niroshan Abayakoon

Reputation: 921

 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
--<c:set var="myvar" scope="page" value = " value="${20}" />
<c:out  value = "${pageScope.str}"  /> ---

Try above code

Upvotes: 1

Related Questions