vendredi 3 avril 2015

Tomcat Context and access External image

I am working in one web Project. I want to show image from the folder which is outside off my webapp and tomcat. I have learn about it and got to know that we can use aliases attribute of context to set the path in context,So that I can access external image. There are many way to configure it. You can directly write it inside Context file of server.But I have learn that,it is not a good pratice to do So.


I have also learn that we can also do by making context.xml file in META-INF file and configure our context. So I have done that.This is my META-INF/context.xml file



<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://ift.tt/jtTJvY

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--><!-- The contents of this file will be loaded for each web application -->
<Context aliases="/images=/home/webwerks/Documents">

<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>META-INF/context.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->

<!-- Uncomment this to enable Comet connection tacking (provides events
on session expiration as well as webapp lifecycle) -->
<!--
<Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
-->

</Context>


My first issue is I am trying to do this in eclipse.I file is added in class path. But it is not working. I don't know What is the issue with it.Please let me know. Thanks for the help


Aucun commentaire:

Enregistrer un commentaire