4

I want to get the current request uri from inside a jsp page in a struts2 webapp. I can do this in an action using the following:

ServletActionContext.getRequest().getRequestURI()

... and I supposed technically I could then create a property of the action that just returns that value but I would rathern not write it into the action, is there a way I can access the same value in a jsp using an ognl expression?

EDIT: After a bit more playing about I have realised that even if I can get the HttpServletRequest.getRequestURI() value in the jsp page by the time I get it, it will have changed to the path of the jsp not the original request URI so will not be what I want.

So instead what I have done is write an interceptor that grabs the value early on before the request is dispatched to the jsp file and then save it in the value stack which I can then refer to it in the jsp. This may be the only solution but if anyone knows different then do enlighten me.

3urdoch
  • 7,192
  • 8
  • 42
  • 58

1 Answers1

1
<s:url/> 

This question Tiles2 Struts Switch Locale shows an application of the tag and shows how to maintain the parameters on the url (which might be useful for later).

Community
  • 1
  • 1
Quaternion
  • 10,380
  • 6
  • 51
  • 102