-2

How to process a excel file without uploading it into server?

also how to upload a file without using the following in to server using servlet,

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.io.FilenameUtils;

Please share me the link or how to do this?

Regards Antony

Joe
  • 4,460
  • 19
  • 60
  • 106
  • So, you want to process the excel file on the client side? using Java Swing, JavaScript of what? – Jonas May 23 '12 at 06:52
  • on the client side? you said you don't want to upload it to a server. Servlets are a server side technology. – Jonas May 23 '12 at 06:54
  • Why don't you want to use `org.apache.commons.*`? If the [FileUpload](http://commons.apache.org/fileupload/) and [IO](http://commons.apache.org/io/) libraries are simply not on your classpath, go download them. – Philipp Reichart May 23 '12 at 06:56
  • Yes,won't we be able to do the same without using servlet? – Joe May 23 '12 at 06:57
  • @Anto What kind of processing do you want to do with Excel files? There's [Apache POI](http://poi.apache.org/) --- I fail to see how this relates to the import statements you posted, though. – Philipp Reichart May 23 '12 at 06:59
  • I am using tomcat 5.5 which doesn't support for annotations, this is the reason why i don't want tot use org.apache.commons.* – Joe May 23 '12 at 06:59
  • Annotations are supported by the JVM, not by Tomcat. Apache Commons Fileupload and IO should be able to run on JDK 1.3 and up (i.e. no there's no annotations in there, they came in 1.4). If your JDK is older, you have way more pressing issues than not being able to use Apache Commons. – Philipp Reichart May 23 '12 at 07:02
  • If you want parse Excel on Client side, only option is ActiveX controls. – Seshagiri May 23 '12 at 07:25
  • @Seshagiri That's simply not true. There's libraries to parse MS Office files in a lot of languages. For Java there's http://poi.apache.org/ – Philipp Reichart May 23 '12 at 07:56

1 Answers1

1

How to process a excel file without uploading it into server?

You could use an applet or webstart application. This is basically kind of a Java Swing application which is embedded in web page. This would then run entirely in the webbrowser without the need to exchange data with the webserver.


also how to upload a file without using the following in to server using servlet

Uh, why do you want to know how to upload a file if you don't want to upload a file? Or is your concrete problem that you have some aversion against including 3rd party libraries in your webapp which would force you to write hundreds if not thousands new lines of code to reinvent the wheel? I'm not sure if I understand...

Anyway, since Servlet 3.0 (Tomcat 7, Glassfish 3, JBoss AS 6, etc) you can use the new HttpServletRequest#getPart() method to retrieve an uploaded file as a part of a multipart/form-data request. Note that all of those servletcontainers use Apache Commons FileUpload transparently under the covers to do the job. The only difference is that you don't need to embed the Apache Commons JARs in your webapp, they are instead embedded in the servletcontainer itself.

For a detailed example how to use the new Servlet 3.0 getPart() method, see also How to upload files to server using JSP/Servlet?

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555