Reputation: 33
Recently, I had an interview and there they asked this question. The question was like this.
Let's say you have one project which is running on localhost. Now, tell me can you able to run this application with two different port at a time?
Upvotes: 0
Views: 158
Reputation: 48077
Nothing blocks an application server to serve two or more ports at the same time - for Tomcat (as you tag it): Use the <Connector>
tag in server.xml to declare connectors for more ports.
As you also tag Liferay: Works as well. A well written application will derive its address from the current request and generate relative URLs based on its current address. It's common to have an application being served on Tomcat and port 8080 (administrative access only), but the port is blocked on the firewall, proxied out as port 80 or better 443. And all of them work.
Before someone jumps onto "well written applications": Of course there are also applications that explicitly redirect to a unique address. But that's rather an explicit decision that's configured/developed. The general case is: Use as many hostnames and ports as you like. The app shouldn't care.
Note that "as many ports/hostnames as you like" might not result in the same outcome: The application is free to interpret the hostname and serve different content for different hostnames (as Liferay does), but again, this is an explicit decision of the authors of the app.
Your question is a yes/no question - that was a long way to say "yes"
Upvotes: 2