File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Url Parsing Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Url Parsing Problem" Watch "Url Parsing Problem" New topic

Url Parsing Problem

Mansoor Ashraf

Joined: Nov 30, 2006
Posts: 3
Hello Folks,

Rookie programmer here, need your suggestion about a little problem. The problem is our application has two URLs, for people trying to access it internally and 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
Scheepers de Bruin
Ranch Hand

Joined: Jul 19, 2005
Posts: 99
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.

We're doomed!!<br />Yay!!!<br />No that's bad Girr!!<br />Yay!!!
I agree. Here's the link:
subject: Url Parsing Problem
It's not a secret anymore!