Results 1 to 5 of 5

Thread: Getting at complete url of current page?

  1. #1

    Default Getting at complete url of current page?

    Hi,

    though not necessarily a Spring question (I think), how can I get at the complete url of the current page in my jsp?

    request.getRequestURI() returns the translated name of my jsp (i.e. something like /blahblah/WEB-INF/views/jsp/signup.jsp).

    Is there a clever way to get the at the url as the user sees it (i.e. http://blah.com/blahblah/signup.html)?

  2. #2
    Join Date
    Dec 2007
    Posts
    130

    Default

    Use
    Code:
    request.getRequestURL().toString()

  3. #3

    Default

    Hi,

    won't work either. Gives me this:

    http://blah.com/blahblah/WEB-INF/views/signup.jsp

    I basically need the unmapped url. I'm using
    SimpleUrlHandlerMapping.

  4. #4
    Join Date
    Dec 2007
    Posts
    130

    Default

    Quote Originally Posted by Jack Hackwerk View Post
    Hi,

    won't work either. Gives me this:

    http://blah.com/blahblah/WEB-INF/views/signup.jsp

    I basically need the unmapped url. I'm using
    SimpleUrlHandlerMapping.
    Really strange. Perhaps you should capture the name in an HttpFilter using request.getRequestURL().toString() and put it in a request attribute. It may work, because the filter is executed before the Spring Servlet, which seems to somehow chage the original url to the mapped one

  5. #5
    Join Date
    Oct 2006
    Posts
    228

    Default

    I'm pretty sure that the InternalResourceViewResolver forwards to the jsp by default, so perhaps try the following:

    Code:
    request.getAttribute("javax.servlet.forward.request_uri");

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •