Question:

I am trying to migrate from weblogic to tomcat. in weblogic I have

<virtual-directory-mapping>
  <local-path>E:/internal</local-path>

For example I have mysite project. It means that localhost:8080/mysite/ = E:/internal and I can get a file from E:/internal through localhost:8080/mysite/

localhost:8080/mysite/file.jsp

I whole project is used:

src="<%=request.getContextPath()%>/file.jsp"

In this article there is an examle how to map local folder to tomcat.

This
6. Now inside the above xml file put the following line: 
<context docbase="d:/images"></context>

doesnt work for me. I changed it to

(1) <Context  docBase="E:/internal"></Context>

It works. But I have a problem. For example I have localhost:8080/mysite/about page.

When I use (1) mapping

src="<%=request.getContextPath()%>/file.jsp" doesnt work because it returns mysite/file.jsp

when I try to map mysite by creating mysite.xml the project is not starting because mysite is a site url.

How can I resolve this problem?

Answer:

The best thing is probably to map each item in E:\Internal individually using the aliases attribute of your <Context> (see http://tomcat.apache.org/tomcat-7.0-doc/config/context.html). Note that using / as an "alias path" is not allowed, which is why you'd have to map each item in E:\Internalindividually.

It would be better if you could use a particular URL space for E:\Internal like /internal/[something] and map the whole directory as an alias, but that might not be feasible for your project.

If you really want to "merge" the two directories (that is, resources from both E:\Internal and CATALINA_BASE/webapps/mysite are available via URLs like /mysite/foo, then you will have to use the VirtualDirContext like this:

<Context>
    <Resources className="org.apache.naming.resources.VirtualDirContext"
      extraResourcePaths="/=E:\Internal" />
</Context>

(See http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Virtual_webapp andhttp://tomcat.apache.org/tomcat-7.0-doc/config/resources.html#VirtualDirContext_implementation).

原文地址:http://stackoverflow.com/questions/20400465/migrate-from-weblogic-to-tomcat-directory-mapping

posted on 2014-08-12 14:59  一天不进步,就是退步  阅读(573)  评论(0编辑  收藏  举报