Normally when I want to get the current page URI in JSP, I can code like this:
String currentUri = request.getRequestURI();
But unfortunately in Struts, I cannot get the current page URI with the above same code. By doing so, I will get the template file URI but not the current page URI.
For Struts, I will need to code like this:
String currentUri = (String)request.getAttribute("javax.servlet.forward.request_uri");
But how if all of my pages are in Struts or JSP? In this case, I will need to get it from Struts URI by default, else wise get from JSP URI.
String currentUri = (String)request.getAttribute("javax.servlet.forward.request_uri");
if (currentUri == null) {
currentUri = request.getRequestURI();
}
Like this, I can handle both case.