This week's book giveaway is in the Web Services forum.
We're giving away four copies of Microservices in Action and have Morgan Bruce & Paulo A. Pereira on-line!
See this thread for details.
Win a copy of Microservices in Action this week in the Web Services forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Accessing webapp context parameters from a custom tag handler  RSS feed

 
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!
 
Marshal
Posts: 67166
169
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
Marshal
Posts: 67166
169
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!
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!