Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Tomcat: mapping or aliasing a directory path

Posted on 2006-06-26
6
415 Views
Last Modified: 2012-06-27
I use several tools (like FCKeditor) in web applications. For every web application I have to copy the code of this tool, and for every update I have to update the tool in all the applications. This is not very efficient. Is there a way to map/alias the tool in every web application to one directory? See the following example:

Tool path: C:\www\tools\FCKeditor\

Application ABC: C:\www\localhost\webapps\abc\
http://localhost:8080/abc/FCKeditor/_samples/default.html

Application XYZ: C:\www\localhost\webapps\xyz\
http://localhost:8080/xyz/FCKeditor/_samples/default.html

There is no directory FCKeditor in either C:\www\localhost\webapps\abc\ or C:\www\localhost\webapps\xyz\.
0
Comment
Question by:grexx
  • 3
  • 2
6 Comments
 
LVL 2

Accepted Solution

by:
Mr_Lenehan earned 250 total points
ID: 16983484
I see you are trying to do it as: http://localhost:8080/appName/FCKeditor/...

This is fine, it will just mean that for every app name you'll need to make a new alias, so you'd add: appName1/FCK and appName2/FCK to the server.xml as oppose to just once... does that make sense?

If not post back, you'd basically need somthing like this added in the <host>:
<Context path="/appName_1/FCKeditor/_samples/defauls"
     docBase="C:/path/to/the/tool"
     defaultSessionTimeOut="30"
     crossContext="false"
     debug="0"
     reloadable="true">
</Context>
<Context path="/appName_2/FCKeditor/_samples/defauls"
     docBase="C:/path/to/the/tool"
     defaultSessionTimeOut="30"
     crossContext="false"
     debug="0"
     reloadable="true">
</Context>

Hope this helps
0
 
LVL 1

Author Comment

by:grexx
ID: 16983983
Thanks. I got it working in server.xml, but read somewhere that I should put this in context.xml. I wonder what the syntax is, because I can't find anything about this. Should I use the context.xml from the server or the META-INF?
0
 
LVL 4

Expert Comment

by:pablomorales
ID: 16984273
You have several options. Take a look at this page:

http://tomcat.apache.org/tomcat-5.5-doc/config/context.html
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 1

Author Comment

by:grexx
ID: 16987235
Okay, I should be more clear. What I'm confused about is how the context.xml is setup. When I open the file in my editor, I see a <context> root. Following xml-guidelines, I may not add another <context> element in the root. So I've tried to add the extra context elements (more than one) inside the context-element, but that didn't work.

This is the context.xml file that comes with the installation:

<!-- The contents of this file will be loaded for each web application -->
<Context>

      <!-- Default set of monitored resources -->
      <WatchedResource>WEB-INF/web.xml</WatchedResource>

      <!-- Uncomment this to disable session persistence across Tomcat restarts -->
      <!--
      <Manager pathname="" />
      -->

</Context>

Where do I add your code? The following doesn't work:

<!-- The contents of this file will be loaded for each web application -->
<Context>

      <!-- Default set of monitored resources -->
      <WatchedResource>WEB-INF/web.xml</WatchedResource>

      <!-- Uncomment this to disable session persistence across Tomcat restarts -->
      <!--
      <Manager pathname="" />
      -->
      <Context path="/appName_2/FCKeditor/_samples/defauls"
            docBase="C:/path/to/the/tool"
            defaultSessionTimeOut="30"
            crossContext="false"
            debug="0"
            reloadable="true">
      </Context>

</Context>

Even using the root-context only, adding the docBase attributes etc, doesn't work.
0
 
LVL 2

Expert Comment

by:Mr_Lenehan
ID: 16987319
make a new file in your conf dir called whateveryoulike.xml the in that file put something like:
<?xml version="1.0" encoding="ISO-8859-1"?>
<Server>
<Host name="yourhost.com" >
<Context path="/applicationname/thatTool"
docBase="c:\some\path"
debug="0" >
<LogSetter name="applicationname_tc.log" path="c:\some\path\applicationname.log" />
<LogSetter name="applicationname_servlet_log"
path="c:\some\path\servlet_applicationname.log"
servletLogger="true"/>
</Context>
</Host>
</Server>

This tells Tomcat to map requests for http://yourhost.com/applicationname/thatTool to the application in the c:\some\path directory.

Give it a whirl and let me know what happens.
0
 
LVL 2

Expert Comment

by:Mr_Lenehan
ID: 16987340
Oh, and when you make that new file, restart Tomcat or it won't go looking for new conf files.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Multiple Images Upload [JSP Web-application] 3 41
gZip compression filter 2 174
How to find missing packages when using Netbeans IDE 8.1 ? 19 59
struts spring hibernate example 12 131
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Some of the SEO trends we might expect in 2017.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question