A solution to this problem anyone ?

On 28 déc 2009, 14:58, Peter Ondruska <[email protected]>
wrote:
> public class Upload extends HttpServlet {
>
>         private static final long serialVersionUID = -7859156850837921885L;
>         private final Logger logger = Logger.getLogger(getClass().getName());
>
>         @SuppressWarnings("unchecked")
>         @Override
>         protected void doPost(final HttpServletRequest request, final
> HttpServletResponse response) throws ServletException,
>                         IOException {
>
>                 response.setContentType("text/plain");
>
>                 if (!ServletFileUpload.isMultipartContent(request))
>                         return;
>
>                 final PersistenceManager pm = 
> PMF.get().getPersistenceManager();
>                 final ServletFileUpload upload = new ServletFileUpload();
>                 upload.setSizeMax(1024*1024-256);
>                 try {
>                         final FileItemIterator iterator = 
> upload.getItemIterator(request);
>                         while (iterator.hasNext()) {
>                                 final FileItemStream fis = iterator.next();
>                                 if (!fis.isFormField()) {
>                                         final String name = fis.getName();
>                                         final String mimeType = 
> fis.getContentType();
>                                         // TODO overwrite existing if owner 
> matches
>                                         final InputStream is = 
> fis.openStream();
>                                         final Blob blob = new 
> Blob(IOUtils.toByteArray(is));
>                                         final Document document = new 
> Document(name, mimeType, blob);
>                                         final UserService us = 
> UserServiceFactory.getUserService();
>                                         final User user = us.getCurrentUser();
>                                         document.setOwner(user);
>                                         pm.makePersistent(document);
>
>                                         Cache cache = null;
>                                         try {
>                                                 CacheFactory cacheFactory = 
> CacheManager.getInstance
> ().getCacheFactory();
>                                                 cache = 
> cacheFactory.createCache(Collections.emptyMap());
>                                                 cache.put("docname~" + name, 
> blob.getBytes());
>                                                 cache.put("doctype~" + name, 
> mimeType);
>                                         } catch (CacheException e) {
>                                                 logger.log(Level.SEVERE, 
> "failed to configure cache", e);
>                                         }
>
>                                 }
>                         }
>                         response.getWriter().write("OK");
>                 } catch (SizeLimitExceededException e) {
>                         response.getWriter().write("Too big");
>                 } catch (FileUploadException e) {
>                         logger.log(Level.SEVERE, null, e);
>                 } finally {
>                         pm.close();
>                 }
>
>         }
>
> }
>
> On 28 pro, 10:56, Andrés Cerezo <[email protected]> wrote:
>
>
>
> > I need more information, can yoyu sen the source code of the program.java ?
>
> > Thanks.
>
> > 2009/12/26 Peter Ondruska <[email protected]>
>
> > > My upload servlet successfully accepts data however the response sent
> > > is not what I expect:
>
> > > <pre style="word-wrap: brak-word; white-space: pre-wrap;">OK</pre>
>
> > > instead of just:
>
> > > OK
>
> > > The servlet basically responds with:
>
> > > response.setContentType("text/plain");
> > > response.getWriter().write("OK");
>
> > > I have tried with curl to post something and servlet (GAE/J SDK) sends
> > > only "OK" but in GWT application I see *<pre style="word-wrap: brak-
> > > word; white-space: pre-wrap;">OK</pre>* when calling event.getResults
> > > ().
>
> > > Any clue what am I doing wrong?
>
> > > --
>
> > > 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%2Bunsubs
> > >  ­[email protected]>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/google-web-toolkit?hl=en.–Skrýt citovaný 
> > >text –
>
> > – Zobrazit citovaný text –

-- 
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