• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Upload files using java(URgent)

 
Ranch Hand
Posts: 469
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Thanks,
How can I do with Java application only (NOT JSP AT ALL)
Thanks,
Angela
 
rubbery bacon. crispy tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!