hi, i'm using <input type="file" name="filename1"> in my jsp.when i was trying to get the parameter in my servlet using getParameter method,i'm getting only null.why is it? can u give me some solution for this. thanx
Metal God
Greenhorn
Joined: Jun 05, 2001
Posts: 2
posted
0
Hi Bala Precisely what you wanted to retrieve? do you want to retrieve a file contents or the filename? MG
phongtran
Greenhorn
Joined: May 29, 2001
Posts: 4
posted
0
Hi Bala Because <input type="file" name="filename1"> is used only for MultiPart form. So that you must use multipart.getParammter() About MultiPart, please contact him // Copyright (C) 1998 by Jason Hunter <jhunter@acm.org>. All rights reserved. // Use of this class is limited. Please see the LICENSE for more information. OR, you can download some java class (package cos.jar) com.oreilly.servlet.multipart.MultipartParser; com.oreilly.servlet.multipart.Part; com.oreilly.servlet.multipart.FilePart; com.oreilly.servlet.multipart.ParamPart;
Bye Quoc Phong
Tran Quoc Phong
saravanan balakrishnan
Greenhorn
Joined: Jun 05, 2001
Posts: 5
posted
0
hi, thanx guys for the reply. i need the filename(from my local system,for example,C:\com\) to my servlet.is there any other method other than Multipart? thanx
phongtran
Greenhorn
Joined: May 29, 2001
Posts: 4
posted
0
Hi You can to use hidden field in your form When you submit, you use JavaScript to get your fileName And then, in your servlet, you must use mutilPart.getParameter() to get your fileName Example: In your HTML file <FORM NAME="UploadFile" ACTION="" ENCTYPE="multipart/form-data" METHOD=POST> <input type="FILE" name="file" value=""> <input type="hidden" name="fileName" value=""> </FORM> <script language="JavaScript"> function onSubmit() { fileName.value = file.value; } </script> In your Servlet file fileName = multiPart.getParameter("fileName"); Have fun, this is my idea, ;-) Quoc Phong