Results 1 to 4 of 4

Thread: Browser URL

  1. #1
    Join Date
    Oct 2005
    Location
    Milan Italy
    Posts
    6

    Default Browser URL

    Hello i can't fetch the browser url.
    I'm using spring controllers and Tiles.

    instead of having http://www.myhost.it:8080/webapp/public/store/store.details.htm

    with those
    Code:
    <tr><td><%=request.getPathInfo()%> </td></tr>
    <tr><td><%=request.getPathTranslated()%></td> </tr>
    <tr><td><%=request.getQueryString() %></td></tr>
    <tr><td><%=request.getRequestURI() %></td></tr>
    <tr><td><%=request.getRequestURL() %></td></tr>
    <tr><td><%=request.getServletPath() %></td></tr>
    <tr><td><%=request.getServletPath() %></td></tr>
    I got

    Code:
    null
    null
    null
    /milkcup/WEB-INF/jsp/base.jsp
    http://www.myHost.it:8080/webapp/WEB-INF/jsp/base.jsp
    /WEB-INF/jsp/base.jsp
    /WEB-INF/jsp/base.jsp
    i need the url for dispatching exceptions depending on url.
    Any ideas?

    thanks!

  2. #2
    Join Date
    Jan 2005
    Posts
    15

    Default

    AFAIR, getRequestURL() from within the controller (not the view) returns the URL you're looking for.

    Regards,
    Esteve

  3. #3
    Join Date
    Aug 2004
    Posts
    123

    Default

    eboix is correct. The request has been redirected to the JSP, so what you are seeing is the request relative to the JSP, not the original URL. What you should do, if you need the original URL in the JSP, is to call request.getRequestURL() in the controller and then put it as a value in the ModelAndView. For example:

    Code:
    return new ModelAndView(getSuccessView(),"originalUrl",request.getRequestURL());
    Or more likely, put it in a Map and use that as the model passed to ModelAndView.

  4. #4
    Join Date
    Oct 2005
    Location
    Milan Italy
    Posts
    6

    Wink

    Actualy i needed the url inside the controller.
    Jsp was just an easy way to see if it is possible to get Url.
    Unfortunally jsp wasn't a useful quick test because is different from the controller.

    From controller works nice.

    Thank you guys!

Posting Permissions

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