Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » How do I include external files in dynamic web project?
How do I include external files in dynamic web project? [message #222721] Sun, 19 October 2008 19:16 Go to next message
Eclipse UserFriend
Originally posted by: erics.nospam.com

I'm specifically thinking about Dojo, but this question pertains to any
external script or html file.

I'm working in Eclipse 3.3 on a dynamic web project destined for Tomcat
server. The external files are on the server in a subdirectory of
"webapps". Let's call it "common". If I refer to it like this in an HTML
file in my project, I know it will load fine when my project is copied over
to the server:

<script language="javascript" src="/common/script1.js"></script>

<a href="/common/page2.html">External HTML file</a>

But how do I get it to work when I'm debugging in Eclipse? It seems that
when I do "debug on server" in Eclipse, it copies my project files to a
temporay directory and runs from there. The problem is that the "common"
subdirectory doesn't exist in that temporary directory. So the scripts in
script1.js don't get loaded and page2.html is not found. Is there some way
to tell the Eclipse project to point to the "common" subdirectory in the
server installation when I'm debugging?

Thanks.
- Eric S.
Re: How do I include external files in dynamic web project? [message #222791 is a reply to message #222721] Mon, 20 October 2008 12:54 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1310
Registered: July 2009
Senior Member
By putting the files under a subdirectory of Tomcat's "webapps" folder,
those files aren't really "external". You have used a convenience
feature of Tomcat where Tomcat automatically tries to serve
subdirectories of "webapps" as if they were Web applications. If you
want to serve these "external" files in the same fashion in Eclipse,
create a second dynamic web project called "common" and put the Dojo
files in its "WebContent" folder. Then add this "common" project to the
Tomcat server that is serving your first project.

Cheers,
Larry

were Web
Eric S. wrote:
> I'm specifically thinking about Dojo, but this question pertains to any
> external script or html file.
>
> I'm working in Eclipse 3.3 on a dynamic web project destined for Tomcat
> server. The external files are on the server in a subdirectory of
> "webapps". Let's call it "common". If I refer to it like this in an HTML
> file in my project, I know it will load fine when my project is copied over
> to the server:
>
> <script language="javascript" src="/common/script1.js"></script>
>
> <a href="/common/page2.html">External HTML file</a>
>
> But how do I get it to work when I'm debugging in Eclipse? It seems that
> when I do "debug on server" in Eclipse, it copies my project files to a
> temporay directory and runs from there. The problem is that the "common"
> subdirectory doesn't exist in that temporary directory. So the scripts in
> script1.js don't get loaded and page2.html is not found. Is there some way
> to tell the Eclipse project to point to the "common" subdirectory in the
> server installation when I'm debugging?
>
> Thanks.
> - Eric S.
>
>
Re: How do I include external files in dynamic web project? [message #222849 is a reply to message #222791] Tue, 21 October 2008 02:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: erics.nospam.com

When I said external, I meant external to my Eclipse project. I don't
really need to put the common directory under webapps. It just needs to be
somewhere on the server where multiple applications can access it. Are you
saying it would be better to be under ROOT?

I guess it would work to create another project and copy the common files
there. But then when I publish/debug, they'll get copied to the temp
directory that Eclipse uses for the server, won't they? So I'll have copies
of those files in 3 places. I was hoping to just have one copy, though. No
way around having mutliple copies?

Thanks.
- Eric S.

"Larry Isaacs" <Larry.Isaacs@sas.com> wrote in message
news:gdhv2h$9ms$1@build.eclipse.org...
> By putting the files under a subdirectory of Tomcat's "webapps" folder,
> those files aren't really "external". You have used a convenience feature
> of Tomcat where Tomcat automatically tries to serve subdirectories of
> "webapps" as if they were Web applications. If you want to serve these
> "external" files in the same fashion in Eclipse, create a second dynamic
> web project called "common" and put the Dojo files in its "WebContent"
> folder. Then add this "common" project to the Tomcat server that is
> serving your first project.
>
> Cheers,
> Larry
>
> were Web
> Eric S. wrote:
>> I'm specifically thinking about Dojo, but this question pertains to any
>> external script or html file.
>>
>> I'm working in Eclipse 3.3 on a dynamic web project destined for Tomcat
>> server. The external files are on the server in a subdirectory of
>> "webapps". Let's call it "common". If I refer to it like this in an
>> HTML file in my project, I know it will load fine when my project is
>> copied over to the server:
>>
>> <script language="javascript" src="/common/script1.js"></script>
>>
>> <a href="/common/page2.html">External HTML file</a>
>>
>> But how do I get it to work when I'm debugging in Eclipse? It seems that
>> when I do "debug on server" in Eclipse, it copies my project files to a
>> temporay directory and runs from there. The problem is that the "common"
>> subdirectory doesn't exist in that temporary directory. So the scripts
>> in script1.js don't get loaded and page2.html is not found. Is there
>> some way to tell the Eclipse project to point to the "common"
>> subdirectory in the server installation when I'm debugging?
>>
>> Thanks.
>> - Eric S.
>>
Re: How do I include external files in dynamic web project? [message #222880 is a reply to message #222849] Tue, 21 October 2008 14:01 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1310
Registered: July 2009
Senior Member
To be shared by multiple applications implies they need to be in their
own webapp, "common" or "ROOT" doesn't really matter. Because Eclipse
is big on separating source from build artifacts, a "publish" is
necessary to get the webapp into a form that can be served, which
requires an additional copy of the resource. Since disk space is cheap,
this shouldn't be a problem.

You do have the option of enabling the "Serve modules without
publishing" option found in the Options section of the server editor
(double-click on the server to open). This uses a "trick" to serve the
projects directly from the workspace. You also have the option of
selecting "Use Tomcat installation..." in the Server Locations section
of the server editor. You could leave the "common" folder under the
webapp's directory of your Tomcat installation, but Eclipse would now
"own" the installation. For details, see the Tomcat FAQ[1].

Cheers,
Larry

[1] http://wiki.eclipse.org/WTP_Tomcat_FAQ


Eric S. wrote:
> When I said external, I meant external to my Eclipse project. I don't
> really need to put the common directory under webapps. It just needs to be
> somewhere on the server where multiple applications can access it. Are you
> saying it would be better to be under ROOT?
>
> I guess it would work to create another project and copy the common files
> there. But then when I publish/debug, they'll get copied to the temp
> directory that Eclipse uses for the server, won't they? So I'll have copies
> of those files in 3 places. I was hoping to just have one copy, though. No
> way around having mutliple copies?
>
> Thanks.
> - Eric S.
>
> "Larry Isaacs" <Larry.Isaacs@sas.com> wrote in message
> news:gdhv2h$9ms$1@build.eclipse.org...
>> By putting the files under a subdirectory of Tomcat's "webapps" folder,
>> those files aren't really "external". You have used a convenience feature
>> of Tomcat where Tomcat automatically tries to serve subdirectories of
>> "webapps" as if they were Web applications. If you want to serve these
>> "external" files in the same fashion in Eclipse, create a second dynamic
>> web project called "common" and put the Dojo files in its "WebContent"
>> folder. Then add this "common" project to the Tomcat server that is
>> serving your first project.
>>
>> Cheers,
>> Larry
>>
>> were Web
>> Eric S. wrote:
>>> I'm specifically thinking about Dojo, but this question pertains to any
>>> external script or html file.
>>>
>>> I'm working in Eclipse 3.3 on a dynamic web project destined for Tomcat
>>> server. The external files are on the server in a subdirectory of
>>> "webapps". Let's call it "common". If I refer to it like this in an
>>> HTML file in my project, I know it will load fine when my project is
>>> copied over to the server:
>>>
>>> <script language="javascript" src="/common/script1.js"></script>
>>>
>>> <a href="/common/page2.html">External HTML file</a>
>>>
>>> But how do I get it to work when I'm debugging in Eclipse? It seems that
>>> when I do "debug on server" in Eclipse, it copies my project files to a
>>> temporay directory and runs from there. The problem is that the "common"
>>> subdirectory doesn't exist in that temporary directory. So the scripts
>>> in script1.js don't get loaded and page2.html is not found. Is there
>>> some way to tell the Eclipse project to point to the "common"
>>> subdirectory in the server installation when I'm debugging?
>>>
>>> Thanks.
>>> - Eric S.
>>>
>
Re: How do I include external files in dynamic web project? [message #222915 is a reply to message #222880] Tue, 21 October 2008 21:17 Go to previous message
Eclipse UserFriend
Originally posted by: ericsn.nospam.no

Thanks. Those sound like pretty good options.

You're right that disk space is cheap. But the Dojo toolkit is large and
the time to copy it is significant. I want to keep those copy operations to
a minimum.

- Eric S.


"Larry Isaacs" <Larry.Isaacs@sas.com> wrote in message
news:gdknb7$b3a$1@build.eclipse.org...
> To be shared by multiple applications implies they need to be in their own
> webapp, "common" or "ROOT" doesn't really matter. Because Eclipse is big
> on separating source from build artifacts, a "publish" is necessary to get
> the webapp into a form that can be served, which requires an additional
> copy of the resource. Since disk space is cheap, this shouldn't be a
> problem.
>
> You do have the option of enabling the "Serve modules without publishing"
> option found in the Options section of the server editor (double-click on
> the server to open). This uses a "trick" to serve the projects directly
> from the workspace. You also have the option of selecting "Use Tomcat
> installation..." in the Server Locations section of the server editor.
> You could leave the "common" folder under the webapp's directory of your
> Tomcat installation, but Eclipse would now "own" the installation. For
> details, see the Tomcat FAQ[1].
>
> Cheers,
> Larry
>
> [1] http://wiki.eclipse.org/WTP_Tomcat_FAQ
>
>
> Eric S. wrote:
>> When I said external, I meant external to my Eclipse project. I don't
>> really need to put the common directory under webapps. It just needs to
>> be somewhere on the server where multiple applications can access it.
>> Are you saying it would be better to be under ROOT?
>>
>> I guess it would work to create another project and copy the common files
>> there. But then when I publish/debug, they'll get copied to the temp
>> directory that Eclipse uses for the server, won't they? So I'll have
>> copies of those files in 3 places. I was hoping to just have one copy,
>> though. No way around having mutliple copies?
>>
>> Thanks.
>> - Eric S.
>>
>> "Larry Isaacs" <Larry.Isaacs@sas.com> wrote in message
>> news:gdhv2h$9ms$1@build.eclipse.org...
>>> By putting the files under a subdirectory of Tomcat's "webapps" folder,
>>> those files aren't really "external". You have used a convenience
>>> feature of Tomcat where Tomcat automatically tries to serve
>>> subdirectories of "webapps" as if they were Web applications. If you
>>> want to serve these "external" files in the same fashion in Eclipse,
>>> create a second dynamic web project called "common" and put the Dojo
>>> files in its "WebContent" folder. Then add this "common" project to the
>>> Tomcat server that is serving your first project.
>>>
>>> Cheers,
>>> Larry
>>>
>>> were Web
>>> Eric S. wrote:
>>>> I'm specifically thinking about Dojo, but this question pertains to any
>>>> external script or html file.
>>>>
>>>> I'm working in Eclipse 3.3 on a dynamic web project destined for Tomcat
>>>> server. The external files are on the server in a subdirectory of
>>>> "webapps". Let's call it "common". If I refer to it like this in an
>>>> HTML file in my project, I know it will load fine when my project is
>>>> copied over to the server:
>>>>
>>>> <script language="javascript" src="/common/script1.js"></script>
>>>>
>>>> <a href="/common/page2.html">External HTML file</a>
>>>>
>>>> But how do I get it to work when I'm debugging in Eclipse? It seems
>>>> that when I do "debug on server" in Eclipse, it copies my project files
>>>> to a temporay directory and runs from there. The problem is that the
>>>> "common" subdirectory doesn't exist in that temporary directory. So
>>>> the scripts in script1.js don't get loaded and page2.html is not found.
>>>> Is there some way to tell the Eclipse project to point to the "common"
>>>> subdirectory in the server installation when I'm debugging?
>>>>
>>>> Thanks.
>>>> - Eric S.
>>>>
>>
Previous Topic:How to contribute to Tomcat's shared/lib?
Next Topic:How to add new features MANUALLY?
Goto Forum:
  


Current Time: Fri Nov 28 17:11:48 GMT 2014

Powered by FUDForum. Page generated in 0.02790 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software