This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.
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.
An IDE is no substitute for an Intelligent Developer.