• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Constructing a URL for redirect

 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
     
    Sheriff
    Posts: 28395
    100
    Eclipse IDE Firefox Browser MySQL Database
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    request.getScheme()
     
    Bala Krishna
    Ranch Hand
    Posts: 95
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thank you. I overlooked that method.
    reply
      Bookmark Topic Watch Topic
    • New Topic