Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Trouble using pageContext in a simple tag handler

 
Nirvikalp Rao
Greenhorn
Posts: 27
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote a simple tag handler class (adviser.java), which extends SimpleTagSupport class. In it's public void doTag() method,
i tried to use JspContext object to access request parameters. Because I have read that method getJspContext() returns
an object, which is actually a pageContext.
The code for my handler class is as follows:



But while compiling this file I am getting a compile time error saying:



What is wrong with my code.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64712
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cast the JSP context to a PageContext.

The sane Java rules apply everywhere. If you have a reference to the superclass of a subclass, you must up-cast to use the methods of the subclass.
 
Nirvikalp Rao
Greenhorn
Posts: 27
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear, After casting ,it's working fine.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64712
86
IntelliJ IDE Java jQuery Mac Mac OS X
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic