jump to navigation

Accessing JSPs kept outside the servlet context May 23, 2009

Posted by Anoop Somasundaran in JSP, Tomcat.
Tags: ,

In one of my projects we had a requirement to access the JSPs/HTMLs which were kept outside the servlet context. The following is the trick that worked for me.

My application was located at /opt/TOMCAT_HOME/webapps/app1 and I had to access (include) the HTML files which were located at a different folder (/folder/files/).

Configuring tomcat to access the Files:

Add the following tag under the <Host name="localhost".. tag in server.xml

<Context path="/app1/files" docBase="/folder/files" debug="0" reloadable="true" crossContext="true"/>

The files for the request http://localhost:8080/app1/files/file.jsp will be fetched from the folder /folder/files.

This will work just fine if you call the JSPs directly. How ever if you want to include the files in a different context in your JSP neither action nor directive will work and will throw error saying that page cannot found.

In my project I had to include the files (HTMLs) in my JSP and the above tags didn’t work.

In this case the JSTL tag <c:import> will work perfectly. Remember that you will have to provide the complete url (http://localhost:8080/app1/files) for the parameter ‘url’ and relative path /app1/files will not work.

<c:import url="http://localhost:8080/app1/files" />

This will help to access the JSPs which are placed in a different context as well. However make sure that you are using crossContext=”true” in the context tag.



1. code highlighter - March 9, 2014

Somebody essentially assist to make critically articles I might state.

That is the first time I frequented your website page and thus far?
I surprised with the research you made to create this actual put up incredible.
Fantastic process!

2. catatanbola.wordpress.com - March 26, 2014

After looking at a handful of the blog articles on your web page, I honestly appreciate your technique of blogging.
I book marked it to my bookmark webpage list and will be
checking back soon. Please check out my website too and let me know what
you think.

3. buy twitter followers no password - March 27, 2014

I don’t even know the way I ended up right here, however I assmed
this put up was once good. I do not know who you might bbe but definitely you are going
to a well-known blogger when you are not already.

4. locksmith - April 21, 2014

I’ve been exploring for a bit for any high-quality articles or blog posts on this kind
of space . Exploring in Yahoo I finally stumbled upon
this web site. Reading this info So i’m glad to convey
that I’ve an incredibly good uncanny feeling I discovered
exactly what I needed. I so much indubitably will
make sure to don?t omit this web site and provides it a look on a constant basis.

5. rovine luna maya - April 29, 2014

This is very interesting, You’re a very skilled blogger.
I’ve joined your feed and look forward to seeking more of your great post.

Also, I have shared your website in my social networks!

6. turrialba Costa Rica house rental - May 12, 2014

Hello, I log on to your blogs like every week.
Your story-telling style is awesome, keep doing what you’re doing!

7. Egm brasil.com.br - May 16, 2014

Wonderful article! This is the type of info that are meant to be
shared across the net. Shame on Google for now not positioning this post upper!
Come on over and discuss with my website . Thanks =)

8. reallifecam free - May 27, 2014

I wanted to thank you for this great read!! I certainly loved every little bit of it.
I have you saved as a favorite to look at new things you

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: