Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
177 views
in Technique[技术] by (71.8m points)

java - How to access request in JspTags?

I want to call request.getContextPath() inside a JSP tag which extends SimpleTagSupport, is there any way to do it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

First get the PageContext by the inherited SimpleTagSupport#getJspContext() and then get the HttpServletRequest by PageContext#getRequest().

PageContext pageContext = (PageContext) getJspContext();  
HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();  

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...