Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Accessing webapp context parameters from a custom tag handler

 
Wally Hartshorn
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm writing a custom tag handler (extending SimpleTagSupport) and need access to the webapp's context-params. In a servlet, I would simply use:



And in a JSP, I would use:



But I can't figure out how to access it directly from my custom tag handler. I could just have my JSP pass it as an attribute via the custom tag, but I'd rather have the custom tag handler access it directly.

Thanks in advance!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65535
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The pageContext gives you access to the request, which gives you the session, which gives you the servlet context.
[ October 07, 2005: Message edited by: Bear Bibeault ]
 
Wally Hartshorn
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bear Bibeault:
The pageContext gives you access to the request, which gives you the session, which gives you the servlet context.


Could you be more specific (i.e. show me the code)? My signature says "Java Novice" for a reason!

Thanks!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65535
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The tricky part is knowing when to cast.

 
Wally Hartshorn
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wonderful! That's exactly what I needed!

For those of you playing along at home, here's my final code:


Thanks!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!