[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 424
  • Last Modified:

Tomcat: mapping or aliasing a directory path

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
grexx
Asked:
grexx
  • 3
  • 2
1 Solution
 
Mr_LenehanCommented:
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
 
grexxAuthor Commented:
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
 
pablomoralesCommented:
You have several options. Take a look at this page:

http://tomcat.apache.org/tomcat-5.5-doc/config/context.html
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
grexxAuthor Commented:
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
 
Mr_LenehanCommented:
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
 
Mr_LenehanCommented:
Oh, and when you make that new file, restart Tomcat or it won't go looking for new conf files.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now