Solved

Upload 5 MB file from a JSP to UNIX box

Posted on 2004-10-01
3
303 Views
Last Modified: 2010-04-01
Hi,

I want to upload a file from a JSP page and put it into a location onto the remote UNIX box.My applcation is deployed in the UNIX box only.

I'd prefer to use only those APIs provided by sun,and not any third party tools.Thanks

Please usggest.
0
Comment
Question by:vishrutsumit
3 Comments
 

Accepted Solution

by:
kheefatt earned 125 total points
ID: 12206107
You can use the MultipartRequest class written by Jason Hunter. Download the jar at http://www.servlets.com/cos/cos-05Nov2002.zip. Extract it and you'll get a filename cosjar.

There is lots of documentation on how to use these classes here:  
http://www.servlets.com/cos/index.html

Put cos.jar in your <application>\WEB-INF\lib\

1) Create an HTML form with upload button. Name it "upload.html":

<html>
<body>
<form action="uploadResult.jsp" method="post" enctype="multipart/form-data">
<input type="file" name=testfile>
<input type=submit>
</form>
</body>
</html>

2) Create another file called "uploadResult.jsp". Inside the file, put :

<%@ page import="com.oreilly.servlet.*" %>
<%
       MultipartRequest(request, "/home/screen/uploads/",10*1000000);
       out.write("Upload Successful");
%>

3) Before u run, create a directory called uploads. As for my case, screen is my login name and I created a directory called uploads under screen. 10*1000000 is where I limit my upload filesize to 10 mb only.

4) Run it and the file should be uploaded into the directory. This work under my UNIX box!

GOOD LUCK!
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Help with LDAp login using jsp 6 115
bean mapper frameworks 5 61
maven project jars 7 54
withoutString  challenge 40 201
This article outlines the process to identify and resolve account lockout in an Active Directory environment.
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question