Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » direct resource path
direct resource path [message #755467] Tue, 08 November 2011 15:29 Go to next message
LordMax is currently offline LordMaxFriend
Messages: 3
Registered: June 2011
Location: Turin (IT)
Junior Member

Hi to all.

I'm a newby of eclipse and of java also so prease, be patience

I have a problem figuring out how to set the path from one file to another.
I have a very trivial structure:

- project
- package1
- src
- file1
- file2
- ...
- static
- static1
- static2
- ...
- WebContent
- WEB-INF
- etc
- users.txt


well
in file1 I need to open users.txt
in file2 I need to write some data into static2.

I can't figure out the path from file1 to data.txt and from file2 to static2 and so on

I've tried (for webcontent):
addItem( user, "./project/WEB-INF/etc/users.txt");
addItem( user, "/project/WEB-INF/etc/users.txt");
addItem( user, "WebContent/WEB-INF/etc/users.txt");
addItem( user, "./project/WebContent/WEB-INF/etc/users.txt");

and so on but nothing works

Can someone help me please?

Thanks
Re: direct resource path [message #757919 is a reply to message #755467] Wed, 16 November 2011 15:44 Go to previous message
Eric Rizzo is currently offline Eric RizzoFriend
Messages: 3071
Registered: July 2009
Senior Member
In general, this is not an Eclipse-specific question and would probably
get more response on a general Java or JEE forum such as stackoverflow.com

I can say that, in general, Java web apps are not supposed to read from
and write to the local file system. I think the JEE spec (and some
containers) even prevent it altogether. Imagine what would happen when
the webapp is deploed as a WAR file, as is often the case? You can't
read/write inside a WAR file.
Google and/or a more general Java/JEE forum can provide some
alternatives to achieving your goal.

Eric


On 11/8/11 10:29 AM, LordMax wrote:
> Hi to all.
>
> I'm a newby of eclipse and of java also so prease, be patience
>
> I have a problem figuring out how to set the path from one file to another.
> I have a very trivial structure:
>
> - project
> - package1
> - src
> - file1
> - file2
> - ...
> - static
> - static1
> - static2
> - ...
> - WebContent
> - WEB-INF
> - etc
> - users.txt
>
>
> well
> in file1 I need to open users.txt
> in file2 I need to write some data into static2.
>
> I can't figure out the path from file1 to data.txt and from file2 to
> static2 and so on
>
> I've tried (for webcontent):
> addItem( user, "./project/WEB-INF/etc/users.txt");
> addItem( user, "/project/WEB-INF/etc/users.txt");
> addItem( user, "WebContent/WEB-INF/etc/users.txt");
> addItem( user, "./project/WebContent/WEB-INF/etc/users.txt");
>
> and so on but nothing works
>
> Can someone help me please?
>
> Thanks
Previous Topic:Tycho vs. Buckminster
Next Topic:How to show rcp plugin A as one of the menu item in rcp plugin B
Goto Forum:
  


Current Time: Fri Jun 25 11:37:43 GMT 2021

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

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

Back to the top