[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.webtools] Re: How to place web files outside the application context?

Bill Davidson wrote:
I'm using eclipse-jee-ganymede-M6 and I can't seem to figure out
how to put files outside of the application context.  In particular,
I would like to put some of my more generic CSS and Javascript files
in top level /css/ and /js/ directories (relative to the server root)
rather than in /MyAppName/css/ or /MyAppName/js/ so that I could use
them with other apps without having multiple copies on my server.

I'm fine with putting them in another project if I need to but I need
them to still be served up by the same local instance of Tomcat 6 that's
serving up MyAppName.  This instance is apparently configured by
Eclipse and puts the files in some funky location deep in the bowels
of the workspace .metadata/.plugins directory.  I need the css/js files
in this instance because I want to use them in my JSP's.  I've tried
creating other web projects, both static and dynamic but I can't seem to
get it right.  It always wants to put the files under the project name/
application context relative to the server root.  I suppose I could
create a project called "css" and another called "js" but that just
feels wrong.

For info about why ".metadata/.plugins/...", see http://wiki.eclipse.org/WTP_Tomcat_FAQ.


As for sharing files "outside of the application context", I believe servlet containers and app servers are designed not to do this for security reasons. Thus, all the resources for a Dynamic Web Project that get published to the server will go somewhere under the base directory for that webapp.

However, I can say that the Tomcat server support in WTP does support a Dynamic Web Project being published as the default context, i.e. the one with a blank context name. This means the "css" and "js" folders of such a project would have URLs like "http://localhost:8080/css/..."; or "http://localhost:8080/js/...";. To achieve this, specify a blank Context Root when you create the Dynamic Web Project. If the project already exists, open its Properties dialog and set the Context Root to blank on the "Web Project Settings" page. When you add this project to a Tomcat server, it will override the ROOT context that WTP provides internally as the default context.

Cheers,
Larry