• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need request.getContextPath() inside a Tag Handler

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, I have been searching through the forums and I have part of the answer, anyway here is what I am doing.

I have a JSP with scripting that I want to eliminate. The scripting uses request.getContextPath and System.currentTimeMillis(). I decided that a tag handler would be the answer. I am trying to get the request object inside a simple tag. I searched the forums and I find that the object returned by getJspContext is really an instance of PageContext (Thanks Bear Bibeault).

So I assume I need this :
private PageContext context;
context = (PageContext) getJspContext();

Okay this should give me the pageContext object. Now I thought I could just do this :
private HttpServletRequest request;
request = context.getRequest();
request.getContextPath();

But I find that pageContext.getRequest returns a ServletRequest and getContextPath() is in HttpServletRequest. So I think I need a HttpServletRequest type ?

Am I missing something ? I feel like this is something obvious but I am having trouble getting there. Thanks in advance for any help !! I am somewhat new to tag handlers.
 
Rod Nichols
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Never mind, I just figured it out, right when I pressed submit. I just cast the request :

request = (HttpServletRequest) context.getRequest();

Can't believe I didn't see that, anyway never mind !!

reply
    Bookmark Topic Watch Topic
  • New Topic