how to Change glassfish application url

2020-08-09 06:09发布

问题:

My current glassfish application can be accessed using this url

localhost:9595/apex

I want to change it to

localhost:9595/pls/apex

what i need change in this case.

回答1:

You can change the context-root for your application by adding a context-root in glassfish-web.xml (If you don't have this file in your project, create it in the WEB-INF folder) like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app error-url="">
    <context-root>/pls/apex</context-root>
</glassfish-web-app>

Update: If this doesn't work you can try to use a sun-web.xml like it is described in this question.



回答2:

Alternatively to using the descriptior glassfish-web.xml you can explicitly definde the context root at deploy time by using the --contextroot switch of asadmin:

asadmin deploy --contextroot="/pls/apex" apex.war

or fill the appropriate context root field in the admin console.