• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic