Get URL Info in JSP

url: http://localhost:8080/img/crew/cover.jsp?p=a

request.getServerName() – localhost

request.getServerPort() – 8080

request.getServletPath() – /crew/cover.jsp

request.getRequestURI() – /img/crew/cover.jsp

request.getRequestURL() – http://localhost:8080/img/crew/cover.jsp

request.getQueryString() – p=a

8 Comments »

  1. steve said

    thanks i found this handy. much appreciated.

  2. Ian in VT said

    This was a very helpful page. Thanks!

  3. Jasmine said

    Thanks!!
    tis very helpful

  4. removeps-generic@yahoo.com said

    How do you get the difference between the URL and URI? That is, how to get the

    http://localhost:8080

  5. longlog said

    use string’s substring function

  6. Silpa said

    I refered some searches that google gave me,but the last but not the least and best one among them is this page for my search.
    I am gratefull to the author.

  7. Yasir Ashfaq said

    Thanks, it very very helpfull.

  8. stephen said

    helpful, thanks

RSS feed for comments on this post · TrackBack URI

Leave a Comment