Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How can I export a file to server using JSP  RSS feed

 
Kiran H Iyer
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to export a file from the client side to a particular directory in server using JSP, the client side should have options like browsing for the particular file from his machine.
kindly help me.
Thanks
regards
Kiran
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This gets covered several times a week, do a search for multipart/form-data or just multipart
Basically you have to tell the browser to upload the form in a different format and provide some data parsing at the server end to cut the content to pieces again since multipart encoding is not usually supported.
Dave
 
maher dabbas
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi .
There is a good package called jspsmart , and it contains a class called JspSmartUploading ,that allow the client to upload any file form the local system to a directory on the web server through a JSP ,use it and you will not regret it.
But , make sure that you set the HTML form encoding for the form that contains the File element as follows
<form action="?.jsp" method="post" ENCTYPE="multipart/form-data">
You can download it from www.jspsmart.com.
Bye.
 
madhu gun
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kiran
1
As maher says,First you set the HTML form encoding for the form that contains the File element as follows
<form action="?.jsp" method="post" ENCTYPE="multipart/form-data">
2
On Server Side
Use
a.import com.oreilly.servlet.MultipartRequest;//download this api first
b.MultipartRequest multi = new MultipartRequest(request, "clear path of any directory on your system",maxSiZe of the file as integer); // 10MB

This should work fine.
Try ..Let us know the result.
regards..
madhu
 
Kiran H Iyer
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Madhu,Maher and David. I will try and let u know the result.
Thanks
regards
kiran
 
Kiran H Iyer
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Madhu, maher
1)I downloaded the jspsmartupload from the site, but I was not able to make it run, in their Sample1.jsp programe they are importing a class com.jspsmartupload, I think when I try to compile the Sample1.jsp, it is not importing the package>Please guide me how to install the package in my system and make it to run.
2)I tried in the Oreilly site to import that particular package named MultipartRequest, but I was not able to locate that, pls guide me how to download this particular programe a and make it to run.
3)I have written a programe on servlets to upload a particular file, the htmL IS MULTIPART/form-data and is working fine for text datas , when I tried to upload an jpg/bmp file it does, but when i tried to view the file , the picture is blurred,not even to identify what the orginal picture looks like. This programe is taken from a book written by Dustin R.Callaway and the publishers are ADDISON_WESLEY.please guide me where the error must have occured and how to solve that.
kindly help me to solve these problems
Thanks
Kiran
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!