Be careful. There's a difference between a relative link the browser
gets and using relative paths in JSP code. In relative URL link for
HTML, the browser computes the full url from the relative path and the
page's base url. JSP is server side and will compute relative path's to
Tomcat's working directory like any java program.
The two methods I suggested below are the recommended ways of accessing
files in your webapps from servlets. After all is said and done, JSPs
are compiled down to servlets for execution. You can also use
javax.servlet.ServletContext#getRealPath() to get the file system
absolute path to a resource in your webapp, but that only works if the
webapp is not being executed from a .war file.
--David
Jignesh Shah wrote:
Yes David, I do use relative path in my jsp's. What
wonders me is I have lots of images in the images
directory and I use them through relative path also
and they work fine. Its only when it comes to css/xsl
files that it cannot access. This stuff again works
fine with other webserver, so I am missing some
necessary jar file in the classpath. I have the
servlet-api.jar file in the classpath.
Thanks,
Jignesh
--- David Smith <[EMAIL PROTECTED]> wrote:
How are you accessing the css/xsl files? Sounds like
you are attempting
to open then with standard Java IO calls and
relative paths. If that's
the case, you might want to consider looking at
javax.servlet.ServletContext#getResource() or
javax.servlet.ServletContext#getResourceAsStream().
These methods allow
you to use context relative paths to resources.
--David
Jignesh Shah wrote:
Hi,
I have a war file that works fine under JRun and
Jetty. Now when I deploy it under
$CATALINA_HOME/webapps directory, the war file
creates
its usual tree under webapps. Now this is what it
looks like after deployment:
/webapps
/myapplication
lots of jsps
css (where I have css and xsl files)
images
WEB-INF
Now my problem is when I access some jsp's after
deployment, in turn they need to access some xsl
files
in css directory, which it cannot find under tomcat
after deployment. The error says that its looking
for
my css/xsl files under $CATALINA_HOME/bin directory
from where I start my tomcat. So again, the
question,
does everything under myapplication is not under
classpath ? What do I do to set it so that it can
find
my css/xsl files.
thanks,
Jignesh
__________________________________________
Yahoo! DSL – Something to write home about.
Just $16.99/mo. or less.
dsl.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail:
[EMAIL PROTECTED]
For additional commands, e-mail:
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail:
[EMAIL PROTECTED]
For additional commands, e-mail:
[EMAIL PROTECTED]
__________________________________________
Yahoo! DSL – Something to write home about.
Just $16.99/mo. or less.
dsl.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]