Pregunta

I'm migrating a webApp from Tomcat to Glassfish. Where do I put a folder, like in the example below, so the webApp can use the css in Glassfish as the same as Tomcat?

Tomcat path (css already working): G:\kdi\apache-tomcat-6.0.32\webapps\ROOT\**myFolder**

Glassfish path: **?**

p.s.: In Tomcat, the html is:

<link rel="stylesheet" href="/myFolder/css/login/login.css"/>

Thanks in advance.

¿Fue útil?

Solución

You can do that by defining an alternate docroot.

If you don't have one, create a glassfish-web.xml 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="">
  <property name="alternatedocroot_1" value="from=/myFolder/* dir=G:/kdi/apache-tomcat-6.0.32/webapps/ROOT/"/>
</glassfish-web-app>

Since it looks like you are on Windows you can use the full path to the folder containing the folder (in your case myFolder) you want to reference.

You can change the path to any location you choose so if you want to to put your files in your GlassFish domain folder you'll have to put myFolder for example in

c:\glassfish3\glassfish\domains\domain1\

and change the property to:

 <property name="alternatedocroot_1" value="from=/myFolder/* dir=c:/glassfish3/glassfish/domains/domain1/"/>

You can reference the files like before:

<link rel="stylesheet" href="/myFolder/css/login/login.css"/>

On non-Windows systems the same should work just without drive letters.

See also:

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top