Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Get Full URL from Header?

 
Drew Lane
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I get the full url (as shown in the address bar) into my JSP page?
I can use 'request.getRequestURI()'
but that only show part of the URL.
What if I want the full thing with http:// and ? parameters, etc.
Thanks,
Drew
 
Peter Kristensson
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use the request.getRequestURL() instead (includes http://...../a.jsp or whatever)
it returns a StringBuffer.
Use request.getQueryString() to get the "a=101&b=202" parameter string.
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
request.getRequestURL() is available with the latest servlet/JSP API. If you are using an older version, you still have to use getRequestURI and just get the host out of the request.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic