aspose file tools*
The moose likes Tomcat and the fly likes How to set Alias name for URL or change  URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "How to set Alias name for URL or change  URL" Watch "How to set Alias name for URL or change  URL" New topic
Author

How to set Alias name for URL or change URL

Balaji Kadam
Ranch Hand

Joined: Apr 27, 2010
Posts: 31

Hi:

I am using Apache Tomcat as web server, it contains multiple web applications.
Url for one of this application is, e.g.http://localhost:8080/myapplication. This particular url work fine.
But i want to use only mypage word instead of all the above url.

So how to set or map this?


Thank You,
Balaji.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16137
    
  21

URLs aren't "magic words". They are Uniform Resource Locators. In other words, the addresses of things. While you can apply a certain amount of aliasing, there are limits.

http: is the protocol name. It tells your browser to use the HTTP protocol, which is a text-based standard protocol.

'//' is a pathname component. It has to be "//' for web URLs, but it can be other things for other protocols. It indicates that the URL is an absolute URL, not a relative URL.

localhost is the name of the host that the request is going to be sent to. It can be an IP address, a local-domain (relative) hostname, or a fully-qualified domain name (FQDN). If a name is used instead of an IP address, the local computer's domain name resolutions mechanisms will be used to lookup the hostname and convert it to an IP address, since the browser has to know the destination IP address in order to send the request. Most browsers will attempt to resolve an unqualified domain name by addressing the "www" server, so for example, I can code "mousetech.com" and the browser will expand it to www,mousetech.com. Localhost is defined as IP address 127.0.0.1 and almost all OS's have it defined somewhere - usually in the "hosts" file.

8080 is the port. Almost every Internet protocol has a default/preferred port (or set of ports). For http, this port is 80, so the "8080" is an override and therefore not optional. DNS resolves ONLY IP addresses, not port numbers, so anything but port 80 MUST be explicitly declared.

myapplication is the name of the web application context that distinguishes one web application from another so that Tomcat will know whuch app the request will be fed to.

Any aliasing or URL-rewriting mechanisms must ultimately resolve to give all of the above information. Any information that isn't supplied will be inferred based on the client's current context. For example, I could specify a URL of "http:mypage" on a http://localhost:8080/myapplication page, and the browser would expand this to http://localhost:8080/myapplication/mypage. However, the browser navigation bar won't have that context, and the browser will typically attempt to expand a "mypage" URL into "http://www.mypage:80/". Unless it gets cute and just decides that's a search request and routes it to bing, google, yahoo, or whoever.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to set Alias name for URL or change URL