How to get the original request url from a servlet/jsp after multiple servlet forwards

前端 未结 6 771

I am working on a cruise booking app using struts/tiles that uses multiple internal servlet/jsp forwards to reach the right jsp for display. But, once you r

6条回答
  •  难免孤独
    2020-12-29 03:50

    You can use a filter to putting origin address to request attribute and then read it from jsp

    Filter mapped to /booking/* execute:

    request.setAttribute("origin", request.getRequestURL());
    

    Jsp:

    ${pageContext.request.attribute["origin"]}
    

    This works because filter has set REQUEST dispatcher by default. It means filter executes only for direct client requests not for forwarding/including

提交回复
热议问题