How to configure Tomcat to serve image files from custom folder or NFS Share.

You can use to Tomcat to serve images, PDF, xls, docx from the custom directory. In our case, we used centralized NFS share to serve images to our custom Apex Applications.

Here is the how

Add a <context> to the tomcat/conf/server.xml file.

Windows example:
<Context docBase=”c:\Documents and Settings\The User\images” path=”/images” />

Linux example:
<Context docBase=”/var/project/images” path=”/images” />

Example of Server.xml (trimmed):

<Server port=”8025″ shutdown=”SHUTDOWN”>

<Service name=”Catalina”>

<Engine name=”Catalina” defaultHost=”localhost”>

<Host appBase=”webapps”
autoDeploy=”false” name=”localhost” unpackWARs=”true”
xmlNamespaceAware=”false” xmlValidation=”false”>

<Host name=”localhost” appBase=”webapps”
unpackWARs=”true” autoDeploy=”true”>

<!–Custom Images Directory–>
<Context docBase=”/nfsshare/custom/images” path=”/images” />

</Host>
</Engine>
</Service>
</Server>

Now, you should be able to pull files (e.g. /nfsshare/custom/images/TestImage.jpg) as http://localhost:8080/custom/images/TestImage.jpg

test

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s