You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by "mn.dheenathayalan Sivam" <si...@gmail.com> on 2008/01/08 09:58:00 UTC

Tomcat 6 + Context path configuration + JSP

dear java,

im using TOMCAT 6.

i have some images in Server's local directory "D:\contents\images". (not
inside in webapps)

i want to show the images in JSP from that server directory. like <img
src="" />

how to give tha path inside src=???

for that im trying to configure context path in conf\context.xml.
code,

<Context path="/contents" docBase="D:\contents\images" debug="0"
reloadable="true" crossContext="true" trusted="true"
privileged="true">
</Context>

in jsp,

<img src="/contents/computers02600tj0.jpg" width="51" height="41" />

but i cant get the result.

reg my above ?, i have created the following file in the name of Context
(MyProject)

reference: http://tomcat.apache.org/tomcat-6.0-doc/config/context.html

For Tomcat 6, unlike Tomcat 4.x, it is NOT recommended to place <Context>
elements directly in the server.xml file. This is because it makes modifing
the Context configuration more invasive since the main conf/server.xml file
cannot be reloaded without restarting Tomcat.

Context elements may be explicitly defined:

in the $CATALINA_HOME/conf/context.xml file: the Context element information
will be loaded by all webapps
in the $CATALINA_HOME/conf/[enginename]/[hostname]/context.xml.default file:
the Context element information will be loaded by all webapps of that host
in individual files (with a ".xml" extension) in the
$CATALINA_HOME/conf/[enginename]/[hostname]/ directory. The name of the file
(less the .xml) extension will be used as the context path. Multi-level
context paths may be defined using #, e.g. context#path.xml. The default web
application may be defined by using a file called ROOT.xml.
if the previous file was not found for this application, in an individual
file at /META-INF/context.xml inside the application files
inside a Host element in the main conf/server.xml

$CATALINA_HOME/conf/[enginename]/[hostname]/ directory.

my Context file:

$CATALINA_HOME/conf/Catalina/localhost/MyProject.xml

MyProject.xml contains

<Context path="/contents" docBase="D:\contents\images\preview"
reloadable="true" crossContext="true" privileged="true" debug="1" />


after using this, my Tomcat server doesnot loaded properly, when i was
trying to restart.

i got below the error in Log file,

Jan 8, 2008 11:07:34 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Jan 8, 2008 11:07:34 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Jan 8, 2008 11:07:34 AM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter CAS Filter
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at edu.yale.its.tp.cas.client.filter.CASFilter.<clinit>(CASFilter.java:87)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(
NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at java.lang.Class.newInstance0(Class.java:350)
at java.lang.Class.newInstance(Class.java:303)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(
ApplicationFilterConfig.java:255)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(
ApplicationFilterConfig.java:397)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(
ApplicationFilterConfig.java:108)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java
:3693)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4340)
at org.apache.catalina.core.ContainerBase.addChildInternal(
ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java
:920)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java
:883)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(
LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java
:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Jan 8, 2008 11:07:34 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextDestroyed()
Jan 8, 2008 11:07:34 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextDestroyed()

plz guid me reg. this. its very URGENT.

tnx.

Re: Tomcat 6 + Context path configuration + JSP

Posted by Roland Pereira <ro...@yahoo.com>.
You could try D:\contents\images  with forward
slashes.

Next you could try   ../../../../../   such that it
takes you right upto the D drive. I dont know you
exact location of webapps.
For e.g if it were in D:/tomcat/webapps then you could
use

../../contents/images

However its always a good idea to move the images
folder to a directory under your webapps folder.

Hope this helps


--- "mn.dheenathayalan Sivam"
<si...@gmail.com> wrote:

> dear java,
> 
> im using TOMCAT 6.
> 
> i have some images in Server's local directory
> "D:\contents\images". (not
> inside in webapps)
> 
> i want to show the images in JSP from that server
> directory. like <img
> src="" />
> 
> how to give tha path inside src=???
> 
> for that im trying to configure context path in
> conf\context.xml.
> code,
> 
> <Context path="/contents"
> docBase="D:\contents\images" debug="0"
> reloadable="true" crossContext="true" trusted="true"
> privileged="true">
> </Context>
> 
> in jsp,
> 
> <img src="/contents/computers02600tj0.jpg"
> width="51" height="41" />
> 
> but i cant get the result.
> 
> reg my above ?, i have created the following file in
> the name of Context
> (MyProject)
> 
> reference:
>
http://tomcat.apache.org/tomcat-6.0-doc/config/context.html
> 
> For Tomcat 6, unlike Tomcat 4.x, it is NOT
> recommended to place <Context>
> elements directly in the server.xml file. This is
> because it makes modifing
> the Context configuration more invasive since the
> main conf/server.xml file
> cannot be reloaded without restarting Tomcat.
> 
> Context elements may be explicitly defined:
> 
> in the $CATALINA_HOME/conf/context.xml file: the
> Context element information
> will be loaded by all webapps
> in the
>
$CATALINA_HOME/conf/[enginename]/[hostname]/context.xml.default
> file:
> the Context element information will be loaded by
> all webapps of that host
> in individual files (with a ".xml" extension) in the
> $CATALINA_HOME/conf/[enginename]/[hostname]/
> directory. The name of the file
> (less the .xml) extension will be used as the
> context path. Multi-level
> context paths may be defined using #, e.g.
> context#path.xml. The default web
> application may be defined by using a file called
> ROOT.xml.
> if the previous file was not found for this
> application, in an individual
> file at /META-INF/context.xml inside the application
> files
> inside a Host element in the main conf/server.xml
> 
> $CATALINA_HOME/conf/[enginename]/[hostname]/
> directory.
> 
> my Context file:
> 
> $CATALINA_HOME/conf/Catalina/localhost/MyProject.xml
> 
> MyProject.xml contains
> 
> <Context path="/contents"
> docBase="D:\contents\images\preview"
> reloadable="true" crossContext="true"
> privileged="true" debug="1" />
> 
> 
> after using this, my Tomcat server doesnot loaded
> properly, when i was
> trying to restart.
> 
> i got below the error in Log file,
> 
> Jan 8, 2008 11:07:34 AM
> org.apache.catalina.core.ApplicationContext log
> INFO: ContextListener: contextInitialized()
> Jan 8, 2008 11:07:34 AM
> org.apache.catalina.core.ApplicationContext log
> INFO: SessionListener: contextInitialized()
> Jan 8, 2008 11:07:34 AM
> org.apache.catalina.core.StandardContext filterStart
> SEVERE: Exception starting filter CAS Filter
> java.lang.NoClassDefFoundError:
> org/apache/commons/logging/LogFactory
> at
>
edu.yale.its.tp.cas.client.filter.CASFilter.<clinit>(CASFilter.java:87)
> at
>
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)
> at
>
sun.reflect.NativeConstructorAccessorImpl.newInstance(
> NativeConstructorAccessorImpl.java:39)
> at
>
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
> DelegatingConstructorAccessorImpl.java:27)
> at
>
java.lang.reflect.Constructor.newInstance(Constructor.java:494)
> at java.lang.Class.newInstance0(Class.java:350)
> at java.lang.Class.newInstance(Class.java:303)
> at
>
org.apache.catalina.core.ApplicationFilterConfig.getFilter(
> ApplicationFilterConfig.java:255)
> at
>
org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(
> ApplicationFilterConfig.java:397)
> at
>
org.apache.catalina.core.ApplicationFilterConfig.<init>(
> ApplicationFilterConfig.java:108)
> at
>
org.apache.catalina.core.StandardContext.filterStart(StandardContext.java
> :3693)
> at
>
org.apache.catalina.core.StandardContext.start(StandardContext.java:4340)
> at
>
org.apache.catalina.core.ContainerBase.addChildInternal(
> ContainerBase.java:791)
> at
>
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
> at
>
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
> at
>
org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java
> :920)
> at
>
org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java
> :883)
> at
>
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
> at
>
org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
> at
>
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
> :311)
> at
>
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(
> LifecycleSupport.java:117)
> at
>
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
> at
>
org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
> at
>
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
> at
>
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
> at
>
org.apache.catalina.core.StandardService.start(StandardService.java:516)
> at
>
org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
> at
>
org.apache.catalina.startup.Catalina.start(Catalina.java:566)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
> at
>
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java
> :39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(
> DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at
>
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
> at
>
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
> Jan 8, 2008 11:07:34 AM
> org.apache.catalina.core.ApplicationContext log
> INFO: SessionListener: contextDestroyed()
> Jan 8, 2008 11:07:34 AM
> org.apache.catalina.core.ApplicationContext log
> INFO: ContextListener: contextDestroyed()
> 
> plz guid me reg. this. its very URGENT.
> 
> tnx.
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@turbine.apache.org
For additional commands, e-mail: user-help@turbine.apache.org