I’m looking to create a local domain mytest.com and have it point to my glassfish application server’s web.xml
I’m coming from a php background where I’d edit my /etc/hosts file and add
127.0.0.1 mytest.com
into my file, then create an apache virtual host that looked for that domain to serve
How can I duplicate this in a java servlet environment? How can I map mytest.com in my web.xml file? I can hit my servlet from localhost:8080 just fine.
thanks
by default Glassfish serves at localhost:8080. If you create an alias for 127.0.0.1 as mytest.com under /etc/hosts you can access your app using http://mytest.com:8080/contextRoot
So basically, you do all the stuffs you were doing in PHP, except you do not need to configure Apache this time. Also, you can change HTTP port from Glassfish admin console (http://localhost:4848) from 8080 to 80, to serve your application from http://mytest.com/contextRoot
Steps are as follows:
You start Glassfish, and deploy your web-application say,
myApp.warormyAppexploded folder.By Default the app will be available at,
http://127.0.0.1:8080/myAppand all the aliases for127.0.0.1likehttp://localhost:8080/myAppNow, you want to alias this with
myTest.com. Go to/etc/hostsadd an alias for 127.0.0.1 like127.0.0.1 localhost myTest.comNow, you can access your application at http://myTest.com:8080/myApp
However, you may further want to smoothen up things, go to
Glassfish Admin Console (http://localhost:4848) > Configuration > HTTP Service > HTTP Listeners > HTTP Listener 1 > Listener Portchange it to80. Now your application will be available athttp://myTest.com/myApp