Re: Fetching images for users: where to put them?

2012-04-06 Thread Sam W
Thanks for your help!

Seems that there isn't a general solution to this...

(Nice tip on checking exist(), I pulled my hair out a few times when I 
forgot to create the folders!)

On Thursday, April 5, 2012 2:35:59 AM UTC+8, Matias Costa wrote:
>
> In web.xml:
>
> 
> imageReceiver
> xxx.ImageReceiver
> 
> 
> imagePath
> /the/place
> 
> 
>
> And in the servlet:
>
> public void init(ServletConfig servletConfig) throws ServletException{
> imagePath = servletConfig.getInitParameter("imagePath");
> if (!imagePath.endsWith(File.separator)) imagePath += File.separator
> try {
> File imageFolder = new File(imagePath);
> if (!File.exists()) Util.mkdirRecursive(imagePath);
> } catch ... whatever you want to do if something fails
>   }
>
> El martes 3 de abril de 2012 03:21:06 UTC+2, Sam W escribió:
>>
>> Hello, 
>>
>> I haven't been able to figure this out after spending 3 hours on 
>> Google. 
>>
>> I can fetch an image, but I don't know where to put them. 
>> If I just use "new File("image.jpg")", it will end up in my tomcat 
>> bin/ folder. 
>>
>> Some sugggests to use getServletContext().getRealPath("/"); but it 
>> would block forever at "getServletContext", I don't know why. 
>>
>> What should I do so it will be part of the war, thus clients can 
>> access it via "http://path.to/appname/images/someimage.jpg";? 
>>
>> What is the best practice on this? 
>>
>> Thank you so much. 
>> Sam
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/LErR8GWTDY4J.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: Fetching images for users: where to put them?

2012-04-04 Thread Matias Costa
In web.xml:


imageReceiver
xxx.ImageReceiver


imagePath
/the/place



And in the servlet:

public void init(ServletConfig servletConfig) throws ServletException{
imagePath = servletConfig.getInitParameter("imagePath");
if (!imagePath.endsWith(File.separator)) imagePath += File.separator
try {
File imageFolder = new File(imagePath);
if (!File.exists()) Util.mkdirRecursive(imagePath);
} catch ... whatever you want to do if something fails
  }

El martes 3 de abril de 2012 03:21:06 UTC+2, Sam W escribió:
>
> Hello, 
>
> I haven't been able to figure this out after spending 3 hours on 
> Google. 
>
> I can fetch an image, but I don't know where to put them. 
> If I just use "new File("image.jpg")", it will end up in my tomcat 
> bin/ folder. 
>
> Some sugggests to use getServletContext().getRealPath("/"); but it 
> would block forever at "getServletContext", I don't know why. 
>
> What should I do so it will be part of the war, thus clients can 
> access it via "http://path.to/appname/images/someimage.jpg";? 
>
> What is the best practice on this? 
>
> Thank you so much. 
> Sam

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/Bv7olVKpJqYJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: Fetching images for users: where to put them?

2012-04-04 Thread Sam W
Turns out getServletContext returns null.

I am using my own tomcat server, so I'm fine with writing files. Except I 
haven't been able to figure out a proper way to get the path.

Currently I use "private static String uglyHardcodedPath = 
"../webapps/myproject/"", the prepend this to all my filepaths...

Thanks everyone

On Tuesday, April 3, 2012 9:21:06 AM UTC+8, Sam W wrote:
>
> Hello, 
>
> I haven't been able to figure this out after spending 3 hours on 
> Google. 
>
> I can fetch an image, but I don't know where to put them. 
> If I just use "new File("image.jpg")", it will end up in my tomcat 
> bin/ folder. 
>
> Some sugggests to use getServletContext().getRealPath("/"); but it 
> would block forever at "getServletContext", I don't know why. 
>
> What should I do so it will be part of the war, thus clients can 
> access it via "http://path.to/appname/images/someimage.jpg";? 
>
> What is the best practice on this? 
>
> Thank you so much. 
> Sam

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/03OtsCQxqRYJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Fetching images for users: where to put them?

2012-04-03 Thread Sam W
Hello,

I haven't been able to figure this out after spending 3 hours on
Google.

I can fetch an image, but I don't know where to put them.
If I just use "new File("image.jpg")", it will end up in my tomcat
bin/ folder.

Some sugggests to use getServletContext().getRealPath("/"); but it
would block forever at "getServletContext", I don't know why.

What should I do so it will be part of the war, thus clients can
access it via "http://path.to/appname/images/someimage.jpg";?

What is the best practice on this?

Thank you so much.
Sam

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.