Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Constructing a URL for redirect  RSS feed

 
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: 22185
    38
    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.
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!