Extend TagSupport and then use pageContext variable.
HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
Question
I am writing a JSP page with custom tags. Normally the page would be like:
<h1>Welcome <%request.getRemoteUser()%> <h1>
I want to introduce custom tags for this instead of having to write script lets. So I decided to write one tag handler. The problem is I do not know a way to get request object in tag handler.
My tag handler looks like:
UserNameTagHandler extends TagSupport{
public int doTag() throws JspException {
String userName = request.getRemoteUser(); //How can I get the correct request object.
}
}
La solution
Extend TagSupport and then use pageContext variable.
HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();