Solved

Tomcat: mapping or aliasing a directory path

Posted on 2006-06-26
6
414 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
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
netstat -a in AIX unix 8 42
trouble with PDF encryption using itext-1.3.1 17 84
memory representation of int[][][] a=new int[2][][]; 10 60
excpetion with multiple catch 11 116
If you thought ransomware was bad, think again! Doxware has the potential to be even more damaging.
SEO can be a real minefield to navigate, but there are three simple ways to up your SEO game just be re-assessing your content output.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

772 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