Hello,
Thank you for your response.  I am a step closer.

Since I am using two servlets (for upload and download) of the image.
do I need to make any changes in .gwt.xml  or web.xml  file?

thanks



On Apr 21, 6:34 am, ahmet terzioglu <[email protected]> wrote:
> Hi,
>
> First of all, I don't save my images in the database, they are saved on the
> web server. Basically you need two http servlets, one for download and one
> for upload. (Maybe you can do it with only one by just using GET and POST
> but anyway...)
>
> For uploading I use a fileUploader widget inside a form. A submit button
> triggers uploadForm.submit() and the file sent to the httpServlet.
>
>         uploadForm.setEncoding(FormPanel.Encoding.MULTIPART);
>         uploadForm.setMethod(FormPanel.Method.POST);
>         uploadForm.setAction(GWT.getModuleBaseURL() +"ServletUpload");
>         ...
>
> The http servlet request is parsed to get the file and write it to the
> webserver. I save my files in directories inside the WEB-INF folder because
> it is private.
>         FileItemFactory factory = new DiskFileItemFactory();
>         ServletFileUpload upload = new ServletFileUpload(factory);
>         List items = upload.parseRequest(req);
>         ...
>
> For downloading all you need is an html img tag calling your downloadServlet
>
>        String serviceCall = GWT.getModuleBaseURL()
> +"ServletDownload?url="+Constants.DOWNLOADPATH+fileName;
>        html.setHTML("<img src=\""+serviceCall+"\" />");
>
> In your httpServlet for download, you take the url paramater from the
> response, find the resource and then stream back to the browser as a
> response using the ServletOutputStream:
>
>         String urlString = request.getParameter("url");
>         response.setContentType("image/jpg");
>         ServletOutputStream out = resp.getOutputStream();
>         URL url = getServletContext().getResource(urlString);
>         ...
>
> By using this approach you can stream an image in a private folder by using
> the servlet call in the html tag to serve the image.
> Hope this helps...
> For more info you can investigate the concepts mentioned Trevis's and
> Subhro's posts.
>
> Ahmet
>
>
>
> On Wed, Apr 21, 2010 at 7:55 AM, KK <[email protected]> wrote:
> > Can you please show an example code .. how you made this work?
>
> > Thanks!
>
> > --
> > 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]<google-web-toolkit%[email protected]>
> > .
> > 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 [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group 
> athttp://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 [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