Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Constructing a URL for redirect

 
Bala Krishna
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I need to construct a fully qualified URL in my JSP, to redirect the client to a page which could be on the same server or on a different server.
Is there a direct way to get the protocol(http or htttps) of the current request ?
I've tried a couple of approaches:
  • request.getProtocol() - returns the string HTTP/1.1. I cannot use this string in my URL, without some kind of string manipulation.
  • request.getURI() - gives me the protocol being used (http:// or https://), but again, I cannot use it without string manipulation.


  • It feels like there should be a simple way to get the protocol of the current request and use it to construct a new fully qualified URL. Any help would be appreciated. Thanks.
     
    Paul Clapham
    Sheriff
    Posts: 21892
    36
    Eclipse IDE Firefox Browser MySQL Database
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    request.getScheme()
     
    Bala Krishna
    Ranch Hand
    Posts: 95
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thank you. I overlooked that method.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!