• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need request.getContextPath() inside a Tag Handler  RSS feed

 
Rod Nichols
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • 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
  • 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 !!

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