Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP Implicit variables in tag files

 
Bharathi Kongara
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,

I've a doubt in the final mock exam. Please help me on that.....

Question 4: I'm not sure why option D is not correct. Why the JSP implict variable pageContext is not available in a tag file? The tag file is by itself a JSP, right?

Thanks for yout time,

Bharathi
 
Bimal Patel
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bharathi,

I think thats not correct. Tag file itself is not a JSP file.
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tags are Java classes. There are no implicit variables in Java classes.

JSPs, on the other hand, must first run through a translator before becoming servlets, which are Java classes. Implicit variables are simply words that the JSP translator understands - it knows how to turn them into meaningful servlet code.
 
Bharathi Kongara
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you guys are talking about the tag handler classes, which are Java classes. But the question I asked is about a tag file, a jsp file renamed with .tag or .tagx extension.
 
Jay Tse
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A Tag File is not the same as a JSP page. It is a JSP fragment. Some of the differences between Tag Files and JSP pages are the directives they use. Tag Files do not use the Page directive, but add three more directives - variable, attribute and tag. Also, when a Tag File is used in a JSP page, its body cannot have any scripting elements, just like Simple Tags. Similarly, because of the internal (web container) implementation of Tag Files, they share more in common with Simple Tags than Classic Tags. Hence, they have access to the JspContext (like Simple Tags) instead of PageContext (like Classic Tags) implicit object.

Hope this helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic