• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Upload files using java(URgent)

 
Ranch Hand
Posts: 469
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I want to upload files from client to server. I wrote simple HTML:
<HTML>
<BODY BGCOLOR="white">
<FORM METHOD="POST" ACTION="/source/test.java/" ENCTYPE="multipart/form-data">
<INPUT TYPE="FILE" NAME="FILE1" SIZE="50"><BR>
<INPUT TYPE="SUBMIT" VALUE="Upload">
</FORM>
</BODY>
</HTML>
Now on server side, I need either Java or JSP to process this form data and get the file contents.
I want to use java application to process form data of HTML. Any Simple java program???
Thanks,
Angela
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can download the package com.oreilly.servlet.MultipartRequest from
http://www.servlets.com/cos/cos-27May2002.zip
the package is free for noncommercial use.. otherwise you shoud buy the book.. read http:// www.servlets.com/cos/license.html for further information
after you have downloaded the package.. simply create 2 .jsp's like following:
upload_form.jsp
------------
<%@ page import="com.oreilly.servlet.MultipartRequest" %>
<form action="save.jsp" method="post" enctype="multipart/form-data">
... <input type="file" name="upload_file"> ...
</form>
save.jsp
-----------
<%
MultipartRequest multipart =
new MultipartRequest(request, dirName,500*1024); // 500 KB max POST size
File f = multipart.getFile("upload_file");
String fileName = multipart.getAbsoluteFilesystemName(name);
%>
 
Angela D'souza
Ranch Hand
Posts: 469
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks,
How can I do with Java application only (NOT JSP AT ALL)
Thanks,
Angela
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic