Re: Loading Images into GWT via MySQL
I'd like to thank the contributors for this discussion, particularly Darren, who provided a nice solution to a problem I had making transient images on the server side and displaying them on the client side. On Mon, Mar 16, 2009 at 12:40 AM, alex.d alex.dukhov...@googlemail.comwrote: Does the img.setUrl(data:image/jpg;base64,...-trick work reliable in all major browsers? On 13 Mrz., 15:07, Darren siegel.dar...@gmail.com wrote: The one case that hasn't been mentioned is when one dynamically creates transient images on the server. We transform various XML data sources into SVG and then transcode into JPG (using Batik) on the fly, then base 64 encode the JPG into a string and send it across via GWT-RPC. Then on the client, once you have the image data from the RPC callback (as a String): String base64EncodedImage = ... ; Image img = new Image(); img.setUrl(data:image/jpg;base64, + base64EncodedImage); On Mar 13, 5:08 am, stone stones...@gmail.com wrote: use a servlet url for downloading img. for example: myapp/dbimage/123456 and the servlet mapping is /dbimage/* On Mar 13, 9:52 am, Itamar Ravid itamar.ira...@gmail.com wrote: Don't forget however to set the content type on the response to an image of some type, otherwise the client's browser will try to download the picture rather than display it. On Fri, Mar 13, 2009 at 2:28 AM, gregor greg.power...@googlemail.comwrote: I think Itamar is right, Jack, you should use a standard HttpServlet for this, not GWT-RPC, because this sends the image over to the browser as byte steam, and I don't think RPC can do that. First, I take it these are not images used in your UI (like icons etc), 'cos those should go in an ImageBundle. I assume you know that these images are downloaded as user selections etc. 1) Consult your MySQL docs/forum to find out how to obtain an InputStream for the image via JDBC. You want to pass an InputStream back to your image download HttpServlet. You don't want to read out the image bytes yet. 2) You write the HttpServlet something like this example (there are lots of others around): http://snippets.dzone.com/posts/show/4629 Notice that the key is a looping read of the InputStream (which you got from MySQL) that writes straight into the HttpServlet's response OutputStream. Notice also it uses a buffer byte[] array. This is so that your web server does not get it's memory clogged up with big image byte arrays - the image bytes just get shunted from the DB straight out to the browser via this buffer. Therefore set this buffer small. Apache tend to use 2048 bytes. I think Oracle prefer 4096. That sort of size for the buffer. Take care to set the response content type so the browser knows what it's dealing with. 3) In your client you can set the Image widget's URL to your image download HttpServlet adding a parameter for the image id. regards gregor On Mar 12, 8:54 pm, fatjack1...@googlemail.com fatjack1...@googlemail.com wrote: Hi, I'm not too sure how to implement a HTTPServlet. Does anyone know how to use images using RPC? Im really stuck on this. On Mar 12, 8:43 pm, Itamar Ravid itamar.ira...@gmail.com wrote: The best way, IMO, is to not use GWT-RPC, but rather implement an HttpServlet, that retrieves the data from the database and returns it with the appropriate Content-Type in response to a GET http request. Then, you simply place an image in your GWT code, with its source being the path to the servlet (defined in your web.xml), passing along any parameters required - such as the ID of the image in the database. On Thu, Mar 12, 2009 at 12:59 PM, fatjack1...@googlemail.com fatjack1...@googlemail.com wrote: Hi, I am new to loading images into GWT from MySQL and am abit lost on the best way to do it. I already have my image in the database. How do I retrieve it? I read somewhere that it can just be stored as a String. Is this correct? So my code on the server side would look like: //Open database connection dc.openConnection(); resultSet = dc.statement.executeQuery(SELECT CategoryImage FROM itemcategory_table WHERE ItemType = 'Test'); while(resultSet.next()) { String test = resultSet.getString(1); } dc.closeConnection(); Or have I got this completely wrong? Next, I need to send this over to the client. What is the best way to send an image over from the server to the client and how should it be stored? Any help on how to use images would be much appreciated! Regards, Jack
Re: Loading Images into GWT via MySQL
Does the img.setUrl(data:image/jpg;base64,...-trick work reliable in all major browsers? On 13 Mrz., 15:07, Darren siegel.dar...@gmail.com wrote: The one case that hasn't been mentioned is when one dynamically creates transient images on the server. We transform various XML data sources into SVG and then transcode into JPG (using Batik) on the fly, then base 64 encode the JPG into a string and send it across via GWT-RPC. Then on the client, once you have the image data from the RPC callback (as a String): String base64EncodedImage = ... ; Image img = new Image(); img.setUrl(data:image/jpg;base64, + base64EncodedImage); On Mar 13, 5:08 am, stone stones...@gmail.com wrote: use a servlet url for downloading img. for example: myapp/dbimage/123456 and the servlet mapping is /dbimage/* On Mar 13, 9:52 am, Itamar Ravid itamar.ira...@gmail.com wrote: Don't forget however to set the content type on the response to an image of some type, otherwise the client's browser will try to download the picture rather than display it. On Fri, Mar 13, 2009 at 2:28 AM, gregor greg.power...@googlemail.comwrote: I think Itamar is right, Jack, you should use a standard HttpServlet for this, not GWT-RPC, because this sends the image over to the browser as byte steam, and I don't think RPC can do that. First, I take it these are not images used in your UI (like icons etc), 'cos those should go in an ImageBundle. I assume you know that these images are downloaded as user selections etc. 1) Consult your MySQL docs/forum to find out how to obtain an InputStream for the image via JDBC. You want to pass an InputStream back to your image download HttpServlet. You don't want to read out the image bytes yet. 2) You write the HttpServlet something like this example (there are lots of others around): http://snippets.dzone.com/posts/show/4629 Notice that the key is a looping read of the InputStream (which you got from MySQL) that writes straight into the HttpServlet's response OutputStream. Notice also it uses a buffer byte[] array. This is so that your web server does not get it's memory clogged up with big image byte arrays - the image bytes just get shunted from the DB straight out to the browser via this buffer. Therefore set this buffer small. Apache tend to use 2048 bytes. I think Oracle prefer 4096. That sort of size for the buffer. Take care to set the response content type so the browser knows what it's dealing with. 3) In your client you can set the Image widget's URL to your image download HttpServlet adding a parameter for the image id. regards gregor On Mar 12, 8:54 pm, fatjack1...@googlemail.com fatjack1...@googlemail.com wrote: Hi, I'm not too sure how to implement a HTTPServlet. Does anyone know how to use images using RPC? Im really stuck on this. On Mar 12, 8:43 pm, Itamar Ravid itamar.ira...@gmail.com wrote: The best way, IMO, is to not use GWT-RPC, but rather implement an HttpServlet, that retrieves the data from the database and returns it with the appropriate Content-Type in response to a GET http request. Then, you simply place an image in your GWT code, with its source being the path to the servlet (defined in your web.xml), passing along any parameters required - such as the ID of the image in the database. On Thu, Mar 12, 2009 at 12:59 PM, fatjack1...@googlemail.com fatjack1...@googlemail.com wrote: Hi, I am new to loading images into GWT from MySQL and am abit lost on the best way to do it. I already have my image in the database. How do I retrieve it? I read somewhere that it can just be stored as a String. Is this correct? So my code on the server side would look like: //Open database connection dc.openConnection(); resultSet = dc.statement.executeQuery(SELECT CategoryImage FROM itemcategory_table WHERE ItemType = 'Test'); while(resultSet.next()) { String test = resultSet.getString(1); } dc.closeConnection(); Or have I got this completely wrong? Next, I need to send this over to the client. What is the best way to send an image over from the server to the client and how should it be stored? Any help on how to use images would be much appreciated! Regards, Jack --~--~-~--~~~---~--~~ 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
Re: Loading Images into GWT via MySQL
Hi, I will give you my honestly opinion. It seems that you are new on the subject and I can say that I have a lot of experience on that. First of all, don't store images on the database :) It is true that we can do it, but depending of what you are going to do, the site of your database will be 90% images and 10% data. The images are always served by httpservers, even if you retrieve it from the database. So if you store the images in the file system of your httpserver, there is no need for network usage in case your database is hosted in a different server. So, use the database just to store the path of your images. Then in GWT, retrieve the object or list of objects that contains the path for your images. Again in GWT, Create an Image object and set the src property. That is all you need to do to display the image. What do you think? Regards, José Vicente On Mar 13, 2:52 am, Itamar Ravid itamar.ira...@gmail.com wrote: Don't forget however to set the content type on the response to an image of some type, otherwise the client's browser will try to download the picture rather than display it. On Fri, Mar 13, 2009 at 2:28 AM, gregor greg.power...@googlemail.comwrote: I think Itamar is right, Jack, you should use a standard HttpServlet for this, not GWT-RPC, because this sends the image over to the browser as byte steam, and I don't think RPC can do that. First, I take it these are not images used in your UI (like icons etc), 'cos those should go in an ImageBundle. I assume you know that these images are downloaded as user selections etc. 1) Consult your MySQL docs/forum to find out how to obtain an InputStream for the image via JDBC. You want to pass an InputStream back to your image download HttpServlet. You don't want to read out the image bytes yet. 2) You write the HttpServlet something like this example (there are lots of others around): http://snippets.dzone.com/posts/show/4629 Notice that the key is a looping read of the InputStream (which you got from MySQL) that writes straight into the HttpServlet's response OutputStream. Notice also it uses a buffer byte[] array. This is so that your web server does not get it's memory clogged up with big image byte arrays - the image bytes just get shunted from the DB straight out to the browser via this buffer. Therefore set this buffer small. Apache tend to use 2048 bytes. I think Oracle prefer 4096. That sort of size for the buffer. Take care to set the response content type so the browser knows what it's dealing with. 3) In your client you can set the Image widget's URL to your image download HttpServlet adding a parameter for the image id. regards gregor On Mar 12, 8:54 pm, fatjack1...@googlemail.com fatjack1...@googlemail.com wrote: Hi, I'm not too sure how to implement a HTTPServlet. Does anyone know how to use images using RPC? Im really stuck on this. On Mar 12, 8:43 pm, Itamar Ravid itamar.ira...@gmail.com wrote: The best way, IMO, is to not use GWT-RPC, but rather implement an HttpServlet, that retrieves the data from the database and returns it with the appropriate Content-Type in response to a GET http request. Then, you simply place an image in your GWT code, with its source being the path to the servlet (defined in your web.xml), passing along any parameters required - such as the ID of the image in the database. On Thu, Mar 12, 2009 at 12:59 PM, fatjack1...@googlemail.com fatjack1...@googlemail.com wrote: Hi, I am new to loading images into GWT from MySQL and am abit lost on the best way to do it. I already have my image in the database. How do I retrieve it? I read somewhere that it can just be stored as a String. Is this correct? So my code on the server side would look like: //Open database connection dc.openConnection(); resultSet = dc.statement.executeQuery(SELECT CategoryImage FROM itemcategory_table WHERE ItemType = 'Test'); while(resultSet.next()) { String test = resultSet.getString(1); } dc.closeConnection(); Or have I got this completely wrong? Next, I need to send this over to the client. What is the best way to send an image over from the server to the client and how should it be stored? Any help on how to use images would be much appreciated! Regards, Jack --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Loading Images into GWT via MySQL
use a servlet url for downloading img. for example: myapp/dbimage/123456 and the servlet mapping is /dbimage/* On Mar 13, 9:52 am, Itamar Ravid itamar.ira...@gmail.com wrote: Don't forget however to set the content type on the response to an image of some type, otherwise the client's browser will try to download the picture rather than display it. On Fri, Mar 13, 2009 at 2:28 AM, gregor greg.power...@googlemail.comwrote: I think Itamar is right, Jack, you should use a standard HttpServlet for this, not GWT-RPC, because this sends the image over to the browser as byte steam, and I don't think RPC can do that. First, I take it these are not images used in your UI (like icons etc), 'cos those should go in an ImageBundle. I assume you know that these images are downloaded as user selections etc. 1) Consult your MySQL docs/forum to find out how to obtain an InputStream for the image via JDBC. You want to pass an InputStream back to your image download HttpServlet. You don't want to read out the image bytes yet. 2) You write the HttpServlet something like this example (there are lots of others around): http://snippets.dzone.com/posts/show/4629 Notice that the key is a looping read of the InputStream (which you got from MySQL) that writes straight into the HttpServlet's response OutputStream. Notice also it uses a buffer byte[] array. This is so that your web server does not get it's memory clogged up with big image byte arrays - the image bytes just get shunted from the DB straight out to the browser via this buffer. Therefore set this buffer small. Apache tend to use 2048 bytes. I think Oracle prefer 4096. That sort of size for the buffer. Take care to set the response content type so the browser knows what it's dealing with. 3) In your client you can set the Image widget's URL to your image download HttpServlet adding a parameter for the image id. regards gregor On Mar 12, 8:54 pm, fatjack1...@googlemail.com fatjack1...@googlemail.com wrote: Hi, I'm not too sure how to implement a HTTPServlet. Does anyone know how to use images using RPC? Im really stuck on this. On Mar 12, 8:43 pm, Itamar Ravid itamar.ira...@gmail.com wrote: The best way, IMO, is to not use GWT-RPC, but rather implement an HttpServlet, that retrieves the data from the database and returns it with the appropriate Content-Type in response to a GET http request. Then, you simply place an image in your GWT code, with its source being the path to the servlet (defined in your web.xml), passing along any parameters required - such as the ID of the image in the database. On Thu, Mar 12, 2009 at 12:59 PM, fatjack1...@googlemail.com fatjack1...@googlemail.com wrote: Hi, I am new to loading images into GWT from MySQL and am abit lost on the best way to do it. I already have my image in the database. How do I retrieve it? I read somewhere that it can just be stored as a String. Is this correct? So my code on the server side would look like: //Open database connection dc.openConnection(); resultSet = dc.statement.executeQuery(SELECT CategoryImage FROM itemcategory_table WHERE ItemType = 'Test'); while(resultSet.next()) { String test = resultSet.getString(1); } dc.closeConnection(); Or have I got this completely wrong? Next, I need to send this over to the client. What is the best way to send an image over from the server to the client and how should it be stored? Any help on how to use images would be much appreciated! Regards, Jack --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Loading Images into GWT via MySQL
I stored images in the filesystem. At the client code, I use image1.setURL( /servlet/...) as 'stone' describes above. An HttpServlet receive it and sends the image (resized in my case). It performs well. On Mar 13, 10:08 am, stone stones...@gmail.com wrote: use a servlet url for downloading img. for example: myapp/dbimage/123456 and the servlet mapping is /dbimage/* On Mar 13, 9:52 am, Itamar Ravid itamar.ira...@gmail.com wrote: Don't forget however to set the content type on the response to an image of some type, otherwise the client's browser will try to download the picture rather than display it. On Fri, Mar 13, 2009 at 2:28 AM, gregor greg.power...@googlemail.comwrote: I think Itamar is right, Jack, you should use a standard HttpServlet for this, not GWT-RPC, because this sends the image over to the browser as byte steam, and I don't think RPC can do that. First, I take it these are not images used in your UI (like icons etc), 'cos those should go in an ImageBundle. I assume you know that these images are downloaded as user selections etc. 1) Consult your MySQL docs/forum to find out how to obtain an InputStream for the image via JDBC. You want to pass an InputStream back to your image download HttpServlet. You don't want to read out the image bytes yet. 2) You write the HttpServlet something like this example (there are lots of others around): http://snippets.dzone.com/posts/show/4629 Notice that the key is a looping read of the InputStream (which you got from MySQL) that writes straight into the HttpServlet's response OutputStream. Notice also it uses a buffer byte[] array. This is so that your web server does not get it's memory clogged up with big image byte arrays - the image bytes just get shunted from the DB straight out to the browser via this buffer. Therefore set this buffer small. Apache tend to use 2048 bytes. I think Oracle prefer 4096. That sort of size for the buffer. Take care to set the response content type so the browser knows what it's dealing with. 3) In your client you can set the Image widget's URL to your image download HttpServlet adding a parameter for the image id. regards gregor On Mar 12, 8:54 pm, fatjack1...@googlemail.com fatjack1...@googlemail.com wrote: Hi, I'm not too sure how to implement a HTTPServlet. Does anyone know how to use images using RPC? Im really stuck on this. On Mar 12, 8:43 pm, Itamar Ravid itamar.ira...@gmail.com wrote: The best way, IMO, is to not use GWT-RPC, but rather implement an HttpServlet, that retrieves the data from the database and returns it with the appropriate Content-Type in response to a GET http request. Then, you simply place an image in your GWT code, with its source being the path to the servlet (defined in your web.xml), passing along any parameters required - such as the ID of the image in the database. On Thu, Mar 12, 2009 at 12:59 PM, fatjack1...@googlemail.com fatjack1...@googlemail.com wrote: Hi, I am new to loading images into GWT from MySQL and am abit lost on the best way to do it. I already have my image in the database. How do I retrieve it? I read somewhere that it can just be stored as a String. Is this correct? So my code on the server side would look like: //Open database connection dc.openConnection(); resultSet = dc.statement.executeQuery(SELECT CategoryImage FROM itemcategory_table WHERE ItemType = 'Test'); while(resultSet.next()) { String test = resultSet.getString(1); } dc.closeConnection(); Or have I got this completely wrong? Next, I need to send this over to the client. What is the best way to send an image over from the server to the client and how should it be stored? Any help on how to use images would be much appreciated! Regards, Jack --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Loading Images into GWT via MySQL
+1 to Ze's comment My reply assumed you had a reason why you *must* store images in DB. If you don't Ze is right that it is a very inefficient way to store and serve images. On Mar 13, 9:04 am, Zé Vicente josevicentec...@gmail.com wrote: Hi, I will give you my honestly opinion. It seems that you are new on the subject and I can say that I have a lot of experience on that. First of all, don't store images on the database :) It is true that we can do it, but depending of what you are going to do, the site of your database will be 90% images and 10% data. The images are always served by httpservers, even if you retrieve it from the database. So if you store the images in the file system of your httpserver, there is no need for network usage in case your database is hosted in a different server. So, use the database just to store the path of your images. Then in GWT, retrieve the object or list of objects that contains the path for your images. Again in GWT, Create an Image object and set the src property. That is all you need to do to display the image. What do you think? Regards, José Vicente On Mar 13, 2:52 am, Itamar Ravid itamar.ira...@gmail.com wrote: Don't forget however to set the content type on the response to an image of some type, otherwise the client's browser will try to download the picture rather than display it. On Fri, Mar 13, 2009 at 2:28 AM, gregor greg.power...@googlemail.comwrote: I think Itamar is right, Jack, you should use a standard HttpServlet for this, not GWT-RPC, because this sends the image over to the browser as byte steam, and I don't think RPC can do that. First, I take it these are not images used in your UI (like icons etc), 'cos those should go in an ImageBundle. I assume you know that these images are downloaded as user selections etc. 1) Consult your MySQL docs/forum to find out how to obtain an InputStream for the image via JDBC. You want to pass an InputStream back to your image download HttpServlet. You don't want to read out the image bytes yet. 2) You write the HttpServlet something like this example (there are lots of others around): http://snippets.dzone.com/posts/show/4629 Notice that the key is a looping read of the InputStream (which you got from MySQL) that writes straight into the HttpServlet's response OutputStream. Notice also it uses a buffer byte[] array. This is so that your web server does not get it's memory clogged up with big image byte arrays - the image bytes just get shunted from the DB straight out to the browser via this buffer. Therefore set this buffer small. Apache tend to use 2048 bytes. I think Oracle prefer 4096. That sort of size for the buffer. Take care to set the response content type so the browser knows what it's dealing with. 3) In your client you can set the Image widget's URL to your image download HttpServlet adding a parameter for the image id. regards gregor On Mar 12, 8:54 pm, fatjack1...@googlemail.com fatjack1...@googlemail.com wrote: Hi, I'm not too sure how to implement a HTTPServlet. Does anyone know how to use images using RPC? Im really stuck on this. On Mar 12, 8:43 pm, Itamar Ravid itamar.ira...@gmail.com wrote: The best way, IMO, is to not use GWT-RPC, but rather implement an HttpServlet, that retrieves the data from the database and returns it with the appropriate Content-Type in response to a GET http request. Then, you simply place an image in your GWT code, with its source being the path to the servlet (defined in your web.xml), passing along any parameters required - such as the ID of the image in the database. On Thu, Mar 12, 2009 at 12:59 PM, fatjack1...@googlemail.com fatjack1...@googlemail.com wrote: Hi, I am new to loading images into GWT from MySQL and am abit lost on the best way to do it. I already have my image in the database. How do I retrieve it? I read somewhere that it can just be stored as a String. Is this correct? So my code on the server side would look like: //Open database connection dc.openConnection(); resultSet = dc.statement.executeQuery(SELECT CategoryImage FROM itemcategory_table WHERE ItemType = 'Test'); while(resultSet.next()) { String test = resultSet.getString(1); } dc.closeConnection(); Or have I got this completely wrong? Next, I need to send this over to the client. What is the best way to send an image over from the server to the client and how should it be stored? Any help on how to use images would be much appreciated! Regards, Jack --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post
Re: Loading Images into GWT via MySQL
Ok, Thanks for all your replies. So which folder should I store the images in? Here is my current folder structure: -bin -src -temp -tomcat -WWW On Mar 13, 10:47 am, gregor greg.power...@googlemail.com wrote: +1 to Ze's comment My reply assumed you had a reason why you *must* store images in DB. If you don't Ze is right that it is a very inefficient way to store and serve images. On Mar 13, 9:04 am, Zé Vicente josevicentec...@gmail.com wrote: Hi, I will give you my honestly opinion. It seems that you are new on the subject and I can say that I have a lot of experience on that. First of all, don't store images on the database :) It is true that we can do it, but depending of what you are going to do, the site of your database will be 90% images and 10% data. The images are always served by httpservers, even if you retrieve it from the database. So if you store the images in the file system of your httpserver, there is no need for network usage in case your database is hosted in a different server. So, use the database just to store the path of your images. Then in GWT, retrieve the object or list of objects that contains the path for your images. Again in GWT, Create an Image object and set the src property. That is all you need to do to display the image. What do you think? Regards, José Vicente On Mar 13, 2:52 am, Itamar Ravid itamar.ira...@gmail.com wrote: Don't forget however to set the content type on the response to an image of some type, otherwise the client's browser will try to download the picture rather than display it. On Fri, Mar 13, 2009 at 2:28 AM, gregor greg.power...@googlemail.comwrote: I think Itamar is right, Jack, you should use a standard HttpServlet for this, not GWT-RPC, because this sends the image over to the browser as byte steam, and I don't think RPC can do that. First, I take it these are not images used in your UI (like icons etc), 'cos those should go in an ImageBundle. I assume you know that these images are downloaded as user selections etc. 1) Consult your MySQL docs/forum to find out how to obtain an InputStream for the image via JDBC. You want to pass an InputStream back to your image download HttpServlet. You don't want to read out the image bytes yet. 2) You write the HttpServlet something like this example (there are lots of others around): http://snippets.dzone.com/posts/show/4629 Notice that the key is a looping read of the InputStream (which you got from MySQL) that writes straight into the HttpServlet's response OutputStream. Notice also it uses a buffer byte[] array. This is so that your web server does not get it's memory clogged up with big image byte arrays - the image bytes just get shunted from the DB straight out to the browser via this buffer. Therefore set this buffer small. Apache tend to use 2048 bytes. I think Oracle prefer 4096. That sort of size for the buffer. Take care to set the response content type so the browser knows what it's dealing with. 3) In your client you can set the Image widget's URL to your image download HttpServlet adding a parameter for the image id. regards gregor On Mar 12, 8:54 pm, fatjack1...@googlemail.com fatjack1...@googlemail.com wrote: Hi, I'm not too sure how to implement a HTTPServlet. Does anyone know how to use images using RPC? Im really stuck on this. On Mar 12, 8:43 pm, Itamar Ravid itamar.ira...@gmail.com wrote: The best way, IMO, is to not use GWT-RPC, but rather implement an HttpServlet, that retrieves the data from the database and returns it with the appropriate Content-Type in response to a GET http request. Then, you simply place an image in your GWT code, with its source being the path to the servlet (defined in your web.xml), passing along any parameters required - such as the ID of the image in the database. On Thu, Mar 12, 2009 at 12:59 PM, fatjack1...@googlemail.com fatjack1...@googlemail.com wrote: Hi, I am new to loading images into GWT from MySQL and am abit lost on the best way to do it. I already have my image in the database. How do I retrieve it? I read somewhere that it can just be stored as a String. Is this correct? So my code on the server side would look like: //Open database connection dc.openConnection(); resultSet = dc.statement.executeQuery(SELECT CategoryImage FROM itemcategory_table WHERE ItemType = 'Test'); while(resultSet.next()) { String test = resultSet.getString(1); } dc.closeConnection(); Or have I got this completely wrong? Next, I need to send this over to the client. What is the best way to send an
Re: Loading Images into GWT via MySQL
The best way, IMO, is to not use GWT-RPC, but rather implement an HttpServlet, that retrieves the data from the database and returns it with the appropriate Content-Type in response to a GET http request. Then, you simply place an image in your GWT code, with its source being the path to the servlet (defined in your web.xml), passing along any parameters required - such as the ID of the image in the database. On Thu, Mar 12, 2009 at 12:59 PM, fatjack1...@googlemail.com fatjack1...@googlemail.com wrote: Hi, I am new to loading images into GWT from MySQL and am abit lost on the best way to do it. I already have my image in the database. How do I retrieve it? I read somewhere that it can just be stored as a String. Is this correct? So my code on the server side would look like: //Open database connection dc.openConnection(); resultSet = dc.statement.executeQuery(SELECT CategoryImage FROM itemcategory_table WHERE ItemType = 'Test'); while(resultSet.next()) { String test = resultSet.getString(1); } dc.closeConnection(); Or have I got this completely wrong? Next, I need to send this over to the client. What is the best way to send an image over from the server to the client and how should it be stored? Any help on how to use images would be much appreciated! Regards, Jack --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Loading Images into GWT via MySQL
Hi, I'm not too sure how to implement a HTTPServlet. Does anyone know how to use images using RPC? Im really stuck on this. On Mar 12, 8:43 pm, Itamar Ravid itamar.ira...@gmail.com wrote: The best way, IMO, is to not use GWT-RPC, but rather implement an HttpServlet, that retrieves the data from the database and returns it with the appropriate Content-Type in response to a GET http request. Then, you simply place an image in your GWT code, with its source being the path to the servlet (defined in your web.xml), passing along any parameters required - such as the ID of the image in the database. On Thu, Mar 12, 2009 at 12:59 PM, fatjack1...@googlemail.com fatjack1...@googlemail.com wrote: Hi, I am new to loading images into GWT from MySQL and am abit lost on the best way to do it. I already have my image in the database. How do I retrieve it? I read somewhere that it can just be stored as a String. Is this correct? So my code on the server side would look like: //Open database connection dc.openConnection(); resultSet = dc.statement.executeQuery(SELECT CategoryImage FROM itemcategory_table WHERE ItemType = 'Test'); while(resultSet.next()) { String test = resultSet.getString(1); } dc.closeConnection(); Or have I got this completely wrong? Next, I need to send this over to the client. What is the best way to send an image over from the server to the client and how should it be stored? Any help on how to use images would be much appreciated! Regards, Jack --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---