Re: How do I send program generated Images to my users?

2010-10-28 Thread Jason Essington
The remote service servlets used by RPC have code in them to prevent GET 
requests from doing anything.

As was said before, if your images are small (or you don't care about IE) you 
can return the image as a data URI (google is your friend here) and when you 
get the response simply do: new Image(myImageDataURI); 

Another option would be to save your image (either to the filesystem, or 
datastore) using some sort of identifier (hash maybe) 

Then use a separate HTTPServlet to return this image something like: 
/GetImage?ID=someid

But your original idea should have worked as well ... 
GWT.getModuleBaseURL()+imageName 

module base url is the location of the Module.js file used in the host page.

There is also GWT.getHostPageBaseURL() which is the location of the Host HTML 
page (which may be different than the module's location) 

-jason

On Oct 26, 2010, at 3:18 PM, Greg Dougherty wrote:

 Thank you Thomas.
 
 Given what I'm trying to do, I need to have the Image created via a
 GWT RPC call.  However, nothing keeps me from implementing doGet ()
 within my servlet, so I did that, and now I can serve up the images
 cleanly, and I can even cache them! :-)
 
 Greg
 
 On Oct 26, 11:26 am, Thomas Broyer t.bro...@gmail.com wrote:
 On 26 oct, 16:18, Greg Dougherty dougherty.greg...@mayo.edu wrote:
 
 
 
 - Generate the image with a servlet on the fly (return the appropriate mime
 type and the image) or (if the images are small)
 
 Great idea.  HOW DO I DO THAT?
 
 Sorry for the shouting, but I'm already generating the things on the
 fly.  If I knew how to return them other than as a file, I'd already
 be doing that.
 
 I've got a GWT client and a GWT Servlet.  The GWT Servlet has an image
 sitting in its memory.  I want to get that image to the client.  If
 you can give me sample code, point me to sample code, or point me to a
 well documented Java function, that would be great, and you would have
 my full appreciation.
 
 Telling me to do X' is pointless, if you don't give me some way of
 figuring out how to DO that X.  Because if I knew how to do it, I
 would have already done it, and not wasted everyone's time with these
 questions.
 
 The thing is: instead of calling your servlet through GWT-RPC or
 whatever (anything implemented above XMLHttpRequest) to generate the
 image; generate the call through a new Image(), passing the
 arguments in the URL.
 Your servlet will then be a bare HttpServlet (no GWT involved, just
 implement de doGet method) and you'd send the image back using the
 HttpServletResponse's OutputStream (after setting the
 HttpServletResponse's content-type to the appropriate value, for
 instance image/png).
 To get the arguments on the server-side, if you passed them in the
 query string, then HttpServletRequest#getParameter will work
 seamlessly.
 
 -- 
 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-tool...@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.
 

-- 
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-tool...@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: How do I send program generated Images to my users?

2010-10-26 Thread ep
if your servlet generates an image, why do you want to get it saved on
the disk? I'd also do it the way Daniel suggested, so just keep your
image generating servlet as standalone, better yet allow extensions so
you can inquire an image not only like /imageGenerator but /
imageGenerator.jpg, then you also dont need to explicitely generate
mime header.

so in web.xml you map your generator:

servlet-mapping
..
 url-pattern/imageGenerator/*/url-pattern
/servlet-mapping

and later, if telling the url of the image in the GWT module, you dont
build the url with getModuleBaseUrl(), but rather use host-relative
url, like new Image(/imageGenerator/whatever.jpg)

you can pass the values to your generator either via url params (/
imageGenerator/image.jpg?name=star) or via pathInfo (/imageGenerator/
image/name/star.jpg)

On 25 Okt., 22:36, Greg Dougherty dougherty.greg...@mayo.edu wrote:
 Hi all,

 My servlet is creating images that I need to send to the client.  My
 first thought was save the image to a file, then send the path to that
 image to the client, which can then call new Image
 (GWT.getModuleBaseURL () + imagePath);

 This worked just fine in the development environment.  But when I
 deploy to Tomcat, if I try to use a relative path, it does it from
 where Tomcat was started, rather than from my module's base.  For
 obvious reasons, I'd prefer not to try to save images to a hard-coded
 path (makes it a bit difficult to move the app around).

 Is there a clean way to get my module's base path, so I can save the
 images relative to that?  If not, what IS the approved way to pass
 program generated images to the client?

 TIA,

 Greg

-- 
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-tool...@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: How do I send program generated Images to my users?

2010-10-26 Thread Greg Dougherty
 - Generate the image with a servlet on the fly (return the appropriate mime
 type and the image) or (if the images are small)

Great idea.  HOW DO I DO THAT?

Sorry for the shouting, but I'm already generating the things on the
fly.  If I knew how to return them other than as a file, I'd already
be doing that.

I've got a GWT client and a GWT Servlet.  The GWT Servlet has an image
sitting in its memory.  I want to get that image to the client.  If
you can give me sample code, point me to sample code, or point me to a
well documented Java function, that would be great, and you would have
my full appreciation.

Telling me to do X' is pointless, if you don't give me some way of
figuring out how to DO that X.  Because if I knew how to do it, I
would have already done it, and not wasted everyone's time with these
questions.

Thank you,

Greg

On Oct 26, 12:42 am, Daniel Kurka kurka.dan...@googlemail.com wrote:
 Hi Greg,

 from my point of view there are to ways of doing this:

 - Generate the image with a servlet on the fly (return the appropriate mime
 type and the image)
 or (if the images are small)
 - you can encode them using base64 and set them as data in an image url

 Hope that helps
 - Daniel Kurka

 2010/10/25 Greg Dougherty dougherty.greg...@mayo.edu

  Hi all,

  My servlet is creating images that I need to send to the client.  My
  first thought was save the image to a file, then send the path to that
  image to the client, which can then call new Image
  (GWT.getModuleBaseURL () + imagePath);

  This worked just fine in the development environment.  But when I
  deploy to Tomcat, if I try to use a relative path, it does it from
  where Tomcat was started, rather than from my module's base.  For
  obvious reasons, I'd prefer not to try to save images to a hard-coded
  path (makes it a bit difficult to move the app around).

  Is there a clean way to get my module's base path, so I can save the
  images relative to that?  If not, what IS the approved way to pass
  program generated images to the client?

  TIA,

  Greg

  --
  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-tool...@googlegroups.com.
  To unsubscribe from this group, send email to
  google-web-toolkit+unsubscr...@googlegroups.comgoogle-web-toolkit%2bunsubscr...@googlegroups.com
  .
  For more options, visit this group at
 http://groups.google.com/group/google-web-toolkit?hl=en.

-- 
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-tool...@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: How do I send program generated Images to my users?

2010-10-26 Thread Thomas Broyer


On 26 oct, 16:18, Greg Dougherty dougherty.greg...@mayo.edu wrote:
  - Generate the image with a servlet on the fly (return the appropriate mime
  type and the image) or (if the images are small)

 Great idea.  HOW DO I DO THAT?

 Sorry for the shouting, but I'm already generating the things on the
 fly.  If I knew how to return them other than as a file, I'd already
 be doing that.

 I've got a GWT client and a GWT Servlet.  The GWT Servlet has an image
 sitting in its memory.  I want to get that image to the client.  If
 you can give me sample code, point me to sample code, or point me to a
 well documented Java function, that would be great, and you would have
 my full appreciation.

 Telling me to do X' is pointless, if you don't give me some way of
 figuring out how to DO that X.  Because if I knew how to do it, I
 would have already done it, and not wasted everyone's time with these
 questions.

The thing is: instead of calling your servlet through GWT-RPC or
whatever (anything implemented above XMLHttpRequest) to generate the
image; generate the call through a new Image(), passing the
arguments in the URL.
Your servlet will then be a bare HttpServlet (no GWT involved, just
implement de doGet method) and you'd send the image back using the
HttpServletResponse's OutputStream (after setting the
HttpServletResponse's content-type to the appropriate value, for
instance image/png).
To get the arguments on the server-side, if you passed them in the
query string, then HttpServletRequest#getParameter will work
seamlessly.

-- 
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-tool...@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: How do I send program generated Images to my users?

2010-10-26 Thread Greg Dougherty
Thank you Thomas.

Given what I'm trying to do, I need to have the Image created via a
GWT RPC call.  However, nothing keeps me from implementing doGet ()
within my servlet, so I did that, and now I can serve up the images
cleanly, and I can even cache them! :-)

Greg

On Oct 26, 11:26 am, Thomas Broyer t.bro...@gmail.com wrote:
 On 26 oct, 16:18, Greg Dougherty dougherty.greg...@mayo.edu wrote:



   - Generate the image with a servlet on the fly (return the appropriate 
   mime
   type and the image) or (if the images are small)

  Great idea.  HOW DO I DO THAT?

  Sorry for the shouting, but I'm already generating the things on the
  fly.  If I knew how to return them other than as a file, I'd already
  be doing that.

  I've got a GWT client and a GWT Servlet.  The GWT Servlet has an image
  sitting in its memory.  I want to get that image to the client.  If
  you can give me sample code, point me to sample code, or point me to a
  well documented Java function, that would be great, and you would have
  my full appreciation.

  Telling me to do X' is pointless, if you don't give me some way of
  figuring out how to DO that X.  Because if I knew how to do it, I
  would have already done it, and not wasted everyone's time with these
  questions.

 The thing is: instead of calling your servlet through GWT-RPC or
 whatever (anything implemented above XMLHttpRequest) to generate the
 image; generate the call through a new Image(), passing the
 arguments in the URL.
 Your servlet will then be a bare HttpServlet (no GWT involved, just
 implement de doGet method) and you'd send the image back using the
 HttpServletResponse's OutputStream (after setting the
 HttpServletResponse's content-type to the appropriate value, for
 instance image/png).
 To get the arguments on the server-side, if you passed them in the
 query string, then HttpServletRequest#getParameter will work
 seamlessly.

-- 
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-tool...@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.



How do I send program generated Images to my users?

2010-10-25 Thread Greg Dougherty
Hi all,

My servlet is creating images that I need to send to the client.  My
first thought was save the image to a file, then send the path to that
image to the client, which can then call new Image
(GWT.getModuleBaseURL () + imagePath);

This worked just fine in the development environment.  But when I
deploy to Tomcat, if I try to use a relative path, it does it from
where Tomcat was started, rather than from my module's base.  For
obvious reasons, I'd prefer not to try to save images to a hard-coded
path (makes it a bit difficult to move the app around).

Is there a clean way to get my module's base path, so I can save the
images relative to that?  If not, what IS the approved way to pass
program generated images to the client?

TIA,

Greg

-- 
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-tool...@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: How do I send program generated Images to my users?

2010-10-25 Thread Daniel Kurka
Hi Greg,

from my point of view there are to ways of doing this:

- Generate the image with a servlet on the fly (return the appropriate mime
type and the image)
or (if the images are small)
- you can encode them using base64 and set them as data in an image url

Hope that helps
- Daniel Kurka


2010/10/25 Greg Dougherty dougherty.greg...@mayo.edu

 Hi all,

 My servlet is creating images that I need to send to the client.  My
 first thought was save the image to a file, then send the path to that
 image to the client, which can then call new Image
 (GWT.getModuleBaseURL () + imagePath);

 This worked just fine in the development environment.  But when I
 deploy to Tomcat, if I try to use a relative path, it does it from
 where Tomcat was started, rather than from my module's base.  For
 obvious reasons, I'd prefer not to try to save images to a hard-coded
 path (makes it a bit difficult to move the app around).

 Is there a clean way to get my module's base path, so I can save the
 images relative to that?  If not, what IS the approved way to pass
 program generated images to the client?

 TIA,

 Greg

 --
 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-tool...@googlegroups.com.
 To unsubscribe from this group, send email to
 google-web-toolkit+unsubscr...@googlegroups.comgoogle-web-toolkit%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/google-web-toolkit?hl=en.



-- 
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-tool...@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.