Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to expose HttpServletRequest to custom tag? 1

Status
Not open for further replies.

manarth

Programmer
Jul 2, 1999
1,705
0
0
GB
My custom tax extends [tt]javax.servlet.jsp.tagext.TagSupport[/tt].

My tag deals with the HTTP Request URIs. This is normally exposed in: [tt]HttpServletRequest.getServletPath[/tt].

However, the TagSupport object only exposes ServletRequest, not HttpServletRequest.

Any ideas?

<marc>
New to Tek-Tips? Get better answers - faq581-3339
 
Cast it:


import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import javax.servlet.http.*;

public class X extends BodyTagSupport {


public int doStartTag() throws JspException
{
HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
....

}
 
very nice - thank you!

works a charm :)

<marc>
New to Tek-Tips? Get better answers - faq581-3339
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top