Win a copy of Spark in Action this week in the Open Source Projects 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
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Accessing webapp context parameters from a custom tag handler

 
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: 67414
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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: 67414
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic