It's actually a very similar problem, conceptually. The
getResourceAsStream() method is the proper way to access your configuration
file. You just need to be more explicit about the location of the file:
// Look for a file in the package "this" belongs to.
this.getClass().getResourceAsStream("myproject.properties");

// Look for a file in the package com.foo.myproject.
this.getClass().getResourceAsStream("/com/foo/myproject/myproject.properties");

See the 
JavaDocs<http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html#getResourceAsStream(java.lang.String)>
for
more details.


On Tue, Oct 7, 2008 at 1:39 PM, Michel <[EMAIL PROTECTED]> wrote:

>
> Thank you both for the responses. I haven't tried it out yet, because
> I am right now stuck with another problem. I wonder if it is caused by
> a similar misunderstanding on my part.
>
> My application needs several files on the server
> (myproject.properties, log4j.properties, hibernate.cfg.xml and so on).
> Now in hosted mode, I have most of those in in the src folder, or in
> the project base folder. I can open a file by: File f = new
> File("myproject.properties") That works fine.
>
> When it comes to deploying in Tomcat, this no longer works. It seems
> now that in hosted mode, I must read a file with these statements:
>
> InputStream fstream =
> this.getClass().getResourceAsStream("myproject.properties");
> props.load(fstream);
>
>
> and now the property file must now sit in the same folder as the class
> with these statements in it.
>
>
> My question is: How can I best organise my resource files, such that
> it works in both hosted and deployed modes. Must I perhaps do
> something similar with GWT.getHostPageBaseURL()?
>
> Thank you very much for your help, and with kind regards,
>
>
> Michel
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to