• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP implicit objects

 
Steven Colley
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, again

For instance:

1- <c:set var="pageContext" value="XXX" scope="page" />
or..
2- <% pageContext.setAttribute("out", "outString" , PageContext.PAGE_SCOPE); %>

3- <% pageContext.setAttribute("exception", "exceptionString" , PageContext.PAGE_SCOPE); %>

4- <%pageContext.setAttribute("page", "pageString" , PageContext.PAGE_SCOPE); %>

Does it overwrite the original implicit objects (in page scope)? or is it a translation error???

Tks.
 
shweta bulbule
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i guess a translation error, coz i don't think weblogic gives u right to play with implicit objects like this.
sorry no solid explanation though.
 
shweta bulbule
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ooops sorry weblogic=jsp
 
Rodrigo Alvarez
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,


I don't think this would lead to an error. Implicit object are not attribute of the pageContext, they just are object that have "naming resolution priority" (please forgive my foreign's English ) against attribute of the pageContext.

Here's what I found in the JSP spec:




=> it looks legal to do a



, only a



would still resolve to the implecit object exception and



would be the attribute.
 
Steven Colley
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI all,

[/QB]
JSP.2.10 Implicit Objects
The EL defines a set of implicit objects which depends on the context in which the EL is being used. When an expression references one of these objects by name, the appropriate object is returned instead of the corresponding attribute. For example in the context of JSP pages, ${pageContext} returns the PageContext object, even if there is an existing pageContext attribute containing some other value.The following implicit objects are available to EL expressions used in JSP
[/QB]


Hi Simon,

You said : "Implicit object are not attribute of the pageContext"..

OK, but i�m not talking about EL issues.
I agree with you. For instance:
We could have this:

EL: {applicationScope.something} , and
PageContext: pageContext.getServletContext()


Originally posted by Felipe Pittella:
Hi, again

For instance:

1- <c:set var="pageContext" value="XXX" scope="page" />
or..
2- <% pageContext.setAttribute("out", "outString" , PageContext.PAGE_SCOPE); %>

3- <% pageContext.setAttribute("exception", "exceptionString" , PageContext.PAGE_SCOPE); %>

4- <%pageContext.setAttribute("page", "pageString" , PageContext.PAGE_SCOPE); %>

Does it overwrite the original implicit objects (in page scope)? or is it a translation error???

Tks.


But the problem for me is..(what i still dindpt figure out..)

--> "outString", "exceptionString" and "pageString" are all "PAGE" scoped attributes, as well as the other implicit ones such as out, exception and page..IN THE SME JSP pagein this case.

What dind�t i figure out?

Tks so much
 
Rodrigo Alvarez
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Felipe;



are all "PAGE" scoped attributes, as well as the other implicit ones such as out, exception and page..IN THE SME JSP pagein this case.


I don't think so. The implicit objects such as out, exception and page are not page scope attributes, they are local variables in the Java translated code. When the JSP file is translated, it ends up as a servlet-like (or maybe it is a servlet, I'm not sure) which declares the implicit objects as local variables of the processing method ( service() ) : the JSP code gives something like :



=> I guess if you refer to out in some JSP code, the translator translates that into a reference to the JspWriter out; above and if you refer to some other attribute you end up with a runtime methode looking for it in every scope. Or maybe it all happens in runtime. In any case I don't think it is a problem to have a page scope attibute with the same name as an implicit object.
[ April 15, 2006: Message edited by: Simon Alvarez ]
 
Steven Colley
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Simon, yes, i guess y�re right.

As far this.."it ends up as a servlet-like (or maybe it is a servlet, I'm not sure)"..Yes, the container works with the Servlet class. Each Engine has its own mechanism to generate the Servlet class in accordance the spec.

And another thing, i got this from a mock:

"pageContext" is also the name of an implicit object, the expression ${pageContext} will evaulate to that object. Therefore, it is not recommended to use names of impicit objects as regular attributes.".

Tks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic