HCRockWorks HCRockWorks - 6 months ago 82
Java Question

How to remove Java Project Name in URL

I have this project name in my eclipse 'abc-work' and when I run it on localhost the url is

http://localhost:8080/abc-work

The default file or page that opens is (as per web.xml below)

<display-name>abc-work</display-name>
<welcome-file-list>
<welcome-file>account/login.xhtml</welcome-file>
</welcome-file-list>


I successfully deployed this application on a cloud and linked it to my domain.

The URL now is:

http://www.abcwork.in/abc-work/

Now, the problem is - I need to remove the last
/abc-work/
from this link, login page should directly open with the link
http://www.abcwork.in/


My project is in Glassfish 3.1.2

I need to make this change, maybe by URL rewriting in web.xml, but I have no clue how to achieve it.

I have tried changing context root from Eclipse project properties, tried changing glassfish-web.xml's context root too - did not work for me.

Any help shall be highly appreciated. Thanks.

Answer

Option 1: You can set one of your webapps as default. This can be done with the admin console:

Configuration --> Virtual Servers --> server

Then select your default web application from the drop-down menu. If your webserver port is 8080, you can start your application now by:

http://hostname:8080

instead of http://hostname:8080/webapp

Notice that "server" is the name of Glassfish's default virtual server. If you configured a different virtual server for your webapp you need to change it accordingly.

Furthermore regarding this source, there might be some problems with JDBCRealms.

Option 2: You could also deploy your default webapp to "/" instead of "/webapp" but I think the first option is more flexible.

Comments