Hobione's Weblog

Living & Breathing in Web 2.0 Era

Alternate/Additional Docroots in GlassFish V2

On window, just type in one line: asadmin set server.http-service.virtual-server.server.property.alternatedocroot_1=”from=/user_document/* dir=c:\ ”
(put a space after the last back-slash, otherwise you will get syntax error)

If you are more familiar with the admin console, you can do this by going to the virtual server page.
Select tree node: Configuration -> HTTP-Service -> Virtual Server -> server
on the right panel, add a row to the property table,
property name: alternatedocroot_1
property value: from=/user_documents/* dir=c:\

You can then access your test.pdf which is put under /user_documents

Click to access test.pdf

1. Keep this in mind that if you have your dir listing disable, you are not able to access dir listing without sending a file name. http://localhost:8080/user_documents (You will get a 404)

2. Make sure there are no context name in the url like this http://localhost:8080/ajw_141/user_documents/test.txt

Full Thread: http://forums.java.net/jive/thread.jspa?messageID=253560
Jan Lueh’s Blog: http://blogs.sun.com/jluehe/entry/alternate_docroots_in_web_applications

——————————————-Episode 2 ———– 01/29/08————————————–

Here how it install in our Sun Solaris:
Glassfish docroot from: /app01/SUNappserver/domains/domain1/docroot
Static content docroot: web/docs

Above example works great in Solaris as well.
property name: alternatedocroot_1
property value: from=/user_documents/* dir=/web/docs

But when I set up my root application to the alternatedocroot, I could not access any of /web/docs directories like user_documents, fileUpload etc. http://atowus2:41877/user_documents/test.txt –> It wont work.

The reason I could not access my /user_documents/test.txt is because, I set up my application root c ontext (/) to glassfish docroot, although I added additional property (alternatedocroot_1), it still kept looking at the glassfish original docroot instead of alternate docroot.

I had couple conditions that I was trying to work with so everything would work seamless like it had been.

1. I wanted to access my homepage page like http://atowus2:41877/ instead of http://atowus2:41877/root

2. I wanted to access my static contents like this: http://atowus2:41877/user_documents/test.pdf

Work around: I kept my root application contents (body, images, WEB-INF, index.jsp etc) under web/docs with other directories, like user_documents, uploadFiles, cm etc.

So instead of previous example, I did the following steps and it seems to be working.

root.jpg

So far, I have resolved these following issues:

1. template path
2. root application path, like http://atowus2:41877/
3. static content path so user should be able to access like this; http://atowus2:41877/user_documents/test.pdf

January 7, 2008 - Posted by | GlassFish

3 Comments »

  1. […] sure read about alternate doc root issue before do this for your glass […]

    Pingback by Glassfish docroot for “Root” application in the server « Hobione’s Weblog | January 29, 2008 | Reply

  2. Adding an Alternate Docroot to my “root” application worked for me in this situation. See the below link:

    http://blogs.sun.com/jluehe/entry/alternate_docroots_in_web_applications

    Comment by Collin | December 2, 2009 | Reply

  3. then, we can rename the for virtual folder, just can using the folder name as it exists at disks.?

    but if want to have two source will same sub folder name . It will have some trouble.

    I think it is not well.

    Comment by fortruth | December 25, 2009 | Reply


Leave a reply to Collin Cancel reply