• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Url Parsing Problem

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Folks,

Rookie programmer here, need your suggestion about a little problem. The problem is our application has two URLs, mycompany.com/Servlet1 for people trying to access it internally and mycompany.org/Servlet1 for the folks outside the company. I need to write conditional logic to interop to a different application based on whether users are coming from the .Com or .ORG URL. What is the best way to do this? Right now I am inclining toward building the url using
URl=(request.getScheme() + "://" +
request.getServerName() + ":" +
request.getServerPort() +
request.getRequestURI()); , and checking whether the user came from the COM or ORG url, Do you guys think this is the best way to do this or is there a better way to solve this problem?

Thanks in advance
 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you only need to check for .com versus .org, you don't really need to build the entire url, the request.getServerName() should contain the .com or .org bits.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic