Re: FileUpload server-side example
Hi Supriya, I'm not completely sure what you mean by whether an application needs to access client and server classes in web mode, but I think your question is where the separation is between your GWT client code and your server-side Java code in the deployed web environment. As you might have imagined it, the GWT compiler generates JavaScript, HTML and applies any CSS rules you've used from your GWT client code. In web mode, these are the resources that you need to deploy to serve the client browser to load up your application. The server-side code must be deployed on the web server as well but is uniquely run on the server-side. To properly deploy your server-side code you'll need to include the compiled .class files as well as any JARs containing the binary for other libraries you are using. As for the problem you are facing with the 404 response when trying to upload a file to the File Upload Servlet, it seems very likely to be that the path you're uploading to isn't the same as the one you've mapped to your File Upload servlet in your web.xml file. Double-check to see where the request is going in the file upload (a number of different HTTP traffic watchers are available and should help in this regard) and match the patch to the one you have defined in your web.xml file. Hope that helps, -Sumit Chandel On Fri, Sep 5, 2008 at 2:41 AM, Supriya Aggarwal <[EMAIL PROTECTED]>wrote: > > Hey thanks a lot for replying! But i wanted to clarify that in web mode do > we need to access client and server classes or it is managed just by all the > generated html and css?? > > > -Supriya > > > On Tue, Sep 2, 2008 at 9:42 AM, Ron Lawrence <[EMAIL PROTECTED]>wrote: > >> >> I am using gwt 1.4.62, and the approach of overriding 'service' is >> working great for my RPC servlet. I am uploading csv files without any >> issue. From the stack trace, it looks like you are handling the >> upload from the "doPost" method rather than from "service". Maybe that >> is the difference. >> >> On Aug 31, 9:53 pm, Madz <[EMAIL PROTECTED]> wrote: >> > Hi, >> > >> > I try your code and it give me this errors when I hit the upload >> > button. >> >> >> > > > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~--~~~~--~~--~--~---
Re: FileUpload server-side example
Hey thanks a lot for replying! But i wanted to clarify that in web mode do we need to access client and server classes or it is managed just by all the generated html and css?? -Supriya On Tue, Sep 2, 2008 at 9:42 AM, Ron Lawrence <[EMAIL PROTECTED]> wrote: > > I am using gwt 1.4.62, and the approach of overriding 'service' is > working great for my RPC servlet. I am uploading csv files without any > issue. From the stack trace, it looks like you are handling the > upload from the "doPost" method rather than from "service". Maybe that > is the difference. > > On Aug 31, 9:53 pm, Madz <[EMAIL PROTECTED]> wrote: > > Hi, > > > > I try your code and it give me this errors when I hit the upload > > button. > > > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~--~~~~--~~--~--~---
Re: FileUpload server-side example
Hey thanks a lot for replying! But can uploading be done using RPC?? I thot we have to just use HTTP servlet for that! -Supriya On Tue, Sep 2, 2008 at 9:42 AM, Ron Lawrence <[EMAIL PROTECTED]> wrote: > > I am using gwt 1.4.62, and the approach of overriding 'service' is > working great for my RPC servlet. I am uploading csv files without any > issue. From the stack trace, it looks like you are handling the > upload from the "doPost" method rather than from "service". Maybe that > is the difference. > > On Aug 31, 9:53 pm, Madz <[EMAIL PROTECTED]> wrote: > > Hi, > > > > I try your code and it give me this errors when I hit the upload > > button. > > > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~--~~~~--~~--~--~---
Re: FileUpload server-side example
I am using gwt 1.4.62, and the approach of overriding 'service' is working great for my RPC servlet. I am uploading csv files without any issue. From the stack trace, it looks like you are handling the upload from the "doPost" method rather than from "service". Maybe that is the difference. On Aug 31, 9:53 pm, Madz <[EMAIL PROTECTED]> wrote: > Hi, > > I try your code and it give me this errors when I hit the upload > button. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~--~~~~--~~--~--~---
Re: FileUpload server-side example
Hi! We are new to GWT and i have some issue coming up with accessing server servlet from client code. I am running compiled GWT code using Jdeveloper 10.1.3.3 Client code gives me the proper interface but when i click on submit to upload the file, then server code comes into picture and it gives me error like:- 404 Not FoundResource *servlet not found on this server Please please help me --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~--~~~~--~~--~--~---
Re: FileUpload server-side example
Hi, I try your code and it give me this errors when I hit the upload button. [INFO] HTTP Status 500 - type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception javax.servlet.ServletException: Servlet execution threw an exception root cause java.lang.StackOverflowError sun.nio.cs.ISO_8859_1$Encoder.encodeArrayLoop(Unknown Source) sun.nio.cs.ISO_8859_1$Encoder.encodeLoop(Unknown Source) java.nio.charset.CharsetEncoder.encode(Unknown Source) java.lang.StringCoding$StringEncoder.encode(Unknown Source) java.lang.StringCoding.encode(Unknown Source) java.lang.String.getBytes(Unknown Source) org.apache.commons.fileupload.FileUploadBase.getBoundary(FileUploadBase.java: 409) org.apache.commons.fileupload.FileUploadBase $FileItemIteratorImpl.(FileUploadBase.java:929) org.apache.commons.fileupload.FileUploadBase.getItemIterator(FileUploadBase.java: 331) org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java: 349) org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java: 126) com.driftmark.ui.server.FileUploadImpl.getFileItem(FileUploadImpl.java: 63) com.driftmark.ui.server.FileUploadImpl.doPost(FileUploadImpl.java:28) javax.servlet.http.HttpServlet.service(HttpServlet.java:709) com.driftmark.ui.server.FileUploadImpl.doPost(FileUploadImpl.java:31) note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs. Apache Tomcat/5.0.28 On Aug 30, 3:29 am, Ron Lawrence <[EMAIL PROTECTED]> wrote: > FYI all, you can use the same RPC servlet to handle thefileupload, > simply override "service" in the RPC servlet, then handle thefileuploadas > shown in the examples above. In the case where it's not > multipart, or there is no uploadedfile, just call super to keep the > RPC framework happy. > > You will also need to set your form's action with > formPanel.setAction( GWT.getModuleBaseURL() + "Servletname" ); use the > same servlet name that's in your module's or web.xmlfile. > > @Override > protected void service( HttpServletRequest request, > HttpServletResponse response ) throws ServletException, > IOException > { > boolean isMultipart = ServletFileUpload.isMultipartContent( new > ServletRequestContext( > request ) ); > if ( isMultipart ) > { > FileItem uploadItem = getFileItem( request ); > if ( uploadItem == null ) > { > super.service( request, response ); > return; > } > > response.setContentType( "text/plain" ); > byte[] fileContents = uploadItem.get(); > // verify thefilehere > String myFile = new String(fileContents); > if (myFile.contains( "" )) > { > //do stuff with the data > response.getWriter().write( "OK" ); > } > else > { > response.getWriter().write( "Invalidfile"); > } > } > else > { > super.service( request, response ); > } > } > > private FileItem getFileItem( HttpServletRequest request ) > { > FileItemFactory factory = new DiskFileItemFactory(); > ServletFileUploadupload= new ServletFileUpload( factory ); > upload.setSizeMax( 1000 ); > > try > { > List items =upload.parseRequest( request ); > for ( FileItem item : items ) > { > if ( !item.isFormField() > && "upload".equals( item.getFieldName() ) ) > { > return item; > } > } > } > catch ( FileUploadException e ) > { > return null; > } > return null; > } --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~--~~~~--~~--~--~---
Re: FileUpload server-side example
Hi, I tried your code an it gives me this errors when I click my upload Button. [INFO] HTTP Status 405 - HTTP method POST is not supported by this URL type Status report message HTTP method POST is not supported by this URL description The specified HTTP method is not allowed for the requested resource (HTTP method POST is not supported by this URL). Apache Tomcat/5.0.28 On Aug 30, 3:29 am, Ron Lawrence <[EMAIL PROTECTED]> wrote: > FYI all, you can use the same RPC servlet to handle thefileupload, > simply override "service" in the RPC servlet, then handle thefileuploadas > shown in the examples above. In the case where it's not > multipart, or there is no uploadedfile, just call super to keep the > RPC framework happy. > > You will also need to set your form's action with > formPanel.setAction( GWT.getModuleBaseURL() + "Servletname" ); use the > same servlet name that's in your module's or web.xmlfile. > > @Override > protected void service( HttpServletRequest request, > HttpServletResponse response ) throws ServletException, > IOException > { > boolean isMultipart = ServletFileUpload.isMultipartContent( new > ServletRequestContext( > request ) ); > if ( isMultipart ) > { > FileItem uploadItem = getFileItem( request ); > if ( uploadItem == null ) > { > super.service( request, response ); > return; > } > > response.setContentType( "text/plain" ); > byte[] fileContents = uploadItem.get(); > // verify thefilehere > String myFile = new String(fileContents); > if (myFile.contains( "" )) > { > //do stuff with the data > response.getWriter().write( "OK" ); > } > else > { > response.getWriter().write( "Invalidfile"); > } > } > else > { > super.service( request, response ); > } > } > > private FileItem getFileItem( HttpServletRequest request ) > { > FileItemFactory factory = new DiskFileItemFactory(); > ServletFileUploadupload= new ServletFileUpload( factory ); > upload.setSizeMax( 1000 ); > > try > { > List items =upload.parseRequest( request ); > for ( FileItem item : items ) > { > if ( !item.isFormField() > && "upload".equals( item.getFieldName() ) ) > { > return item; > } > } > } > catch ( FileUploadException e ) > { > return null; > } > return null; > } --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~--~~~~--~~--~--~---
Re: FileUpload server-side example
FYI all, you can use the same RPC servlet to handle the file upload, simply override "service" in the RPC servlet, then handle the file upload as shown in the examples above. In the case where it's not multipart, or there is no uploaded file, just call super to keep the RPC framework happy. You will also need to set your form's action with formPanel.setAction( GWT.getModuleBaseURL() + "Servletname" ); use the same servlet name that's in your module's or web.xml file. @Override protected void service( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException { boolean isMultipart = ServletFileUpload.isMultipartContent( new ServletRequestContext( request ) ); if ( isMultipart ) { FileItem uploadItem = getFileItem( request ); if ( uploadItem == null ) { super.service( request, response ); return; } response.setContentType( "text/plain" ); byte[] fileContents = uploadItem.get(); // verify the file here String myFile = new String(fileContents); if (myFile.contains( "" )) { //do stuff with the data response.getWriter().write( "OK" ); } else { response.getWriter().write( "Invalid file"); } } else { super.service( request, response ); } } private FileItem getFileItem( HttpServletRequest request ) { FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload( factory ); upload.setSizeMax( 1000 ); try { List items = upload.parseRequest( request ); for ( FileItem item : items ) { if ( !item.isFormField() && "upload".equals( item.getFieldName() ) ) { return item; } } } catch ( FileUploadException e ) { return null; } return null; } --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~--~~~~--~~--~--~---