<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Welcome to my world. &#187; virtual directory</title>
	<atom:link href="http://www.marceble.com/tag/virtual-directory/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.marceble.com</link>
	<description>Marc E. Eble</description>
	<lastBuildDate>Thu, 22 Apr 2010 20:47:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Virtual Directories in Glassfish</title>
		<link>http://www.marceble.com/2009/07/virtual-directories-in-glassfish/</link>
		<comments>http://www.marceble.com/2009/07/virtual-directories-in-glassfish/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 11:55:09 +0000</pubDate>
		<dc:creator>Marc</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Glassfish]]></category>
		<category><![CDATA[JAVA]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[virtual directory]]></category>

		<guid isPermaLink="false">http://www.marceble.com/?p=121</guid>
		<description><![CDATA[There are many reasons you may want some of your content outside of the application server root. Perhaps you wish to share the content between applications or even webservers, or maybe you temporarily write data from a database to be served. Regardless, serving static content in glassfish is extremely easy. There are two ways to accomplish [...]]]></description>
			<content:encoded><![CDATA[<p id="top" />There are many reasons you may want some of your content outside of the application server root. Perhaps you wish to share the content between applications or even webservers, or maybe you temporarily write data from a database to be served. Regardless, serving static content in glassfish is extremely easy. There are two ways to accomplish this; at the server level and at the application level.</p>
<h3>Server level</h3>
<p>First we will look at the server level, this will make your information available server wide, outside of any application context. Lets say you have images you wish to serve in the directory C:\media. In the glassfish admin console expand configuration &gt; http service &gt; virtual servers. Select &#8216;server&#8217; then scroll to the bottom and select &#8216;add property&#8217;.</p>
<p>For name use: <em><strong>alternatedocroot_1</strong>,</em> for value use: <em><strong>from=/media/* dir=C:/</strong></em></p>
<p>Keep in mind that glassfish expects the directory in the URL pattern to exist, so the <em><strong>from=</strong></em> is not just the URL pattern, but it is also the path relative to the <em><strong>dir=</strong></em>.</p>
<p><span id="more-121"></span>Luckily these changes do not require any restarts so you can experiment easily to make sure you have the settings you want. If you used the default glassfish install and your server runs at <a  href="http://localhost:8080">http://localhost:8080</a> then <a  href="http://localhost:8080/media/">http://localhost:8080/media/</a> should now resolve to the absolute path C:\media.</p>
<p style="TEXT-ALIGN: center"><a  href="http://www.marceble.com/virtualdirectories.jpg" target="_blank" class="thickbox no_icon" rel="gallery-121" title="virtualdirectories"><img class="aligncenter" title="virtualdirectories" src="http://www.marceble.com/virtualdirectories.jpg" alt="Using virtual directories in Glassfish." width="1013" height="596" /></a></p>
<p style="TEXT-ALIGN: center"><em>The image above shows adding an alternate docroot from in the admin console, click it for the full sized image.</em></p>
<p style="TEXT-ALIGN: center">
<h3>Application Level</h3>
<p>Let&#8217;s say you have an application <em>WebApplication1</em>. By editing sun-web.xml you can add an alternate docroot that is relative to the application. For this example I will use the same as above, serving /media/* from C:/.</p>
<p>Add the following line to <strong>sun-web.xml</strong> inside the <strong>&lt;sun-web-app&gt;</strong> tag:</p>
<p><strong>&lt;property name=&#8221;alternatedocroot_1&#8243; value=&#8221;from=/media/* dir=C:/&#8221;/&gt;</strong></p>
<p>If using the default glassfish setup, <a  href="http://localhost:8080/WebApplication1/media/">http://localhost:8080/WebApplication1/media/</a> should now resolve to the absolute directory C:\media</p>
<p style="text-align: center;"><a  href="http://www.marceble.com/sunwebxml.jpg" target="_blank" class="thickbox no_icon" rel="gallery-121" title="sunwebxml"><img class=" aligncenter" title="sunwebxml" src="http://www.marceble.com/sunwebxml.jpg" alt="alternate docroot in sun-web.xml" width="1042" height="678" /></a></p>
<p style="TEXT-ALIGN: center"><em> The image above shows an example of sun-web.xml. Click for full size.</em></p>
<p style="TEXT-ALIGN: left">In both of the above scenarios you can have as many alternate docroots as you want, as long as the follow the naming convention (alternatedocroot_1, alternatedocroot_2, etc&#8230;). Also your url pattern can be as specific as you like, for instance if you only wanted to catch requests for jpeg&#8217;s in the media directory then you would use: from=/media/*.jpg</p>
<p style="TEXT-ALIGN: left">
]]></content:encoded>
			<wfw:commentRss>http://www.marceble.com/2009/07/virtual-directories-in-glassfish/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

