Announcement Announcement Module
Collapse
No announcement yet.
Browser URL Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    AFAIR, getRequestURL() from within the controller (not the view) returns the URL you're looking for.

    Regards,
    Esteve

    Comment


    • #3
      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.

      Comment


      • #4
        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!

        Comment

        Working...
        X