Solved

Tomcat: mapping or aliasing a directory path

Posted on 2006-06-26
6
412 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Fisheye tool 2 101
TreeSet comparator example 7 87
Retrieving file from bytes array in spring mvc 8 51
own marker interface 1 44
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
A safe way to clean winsxs folder from your windows server 2008 R2 editions
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

707 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now