This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes using file chooser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "using file chooser " Watch "using file chooser " New topic

using file chooser

sravanthi sri

Joined: Sep 04, 2005
Posts: 2
hi friends
when i upload files using file chooser described in following code

<form METHOD=post ACTION="JspFileName.jsp"
<input TYPE="file" NAME="filename">

its working fine when am uploading files via server system ...when i try to
upload files from any other system . my server is searching for client specified file path in server ...there fore FileNotFoundException is araising

please help me how to resolve this problem

Ben Souther

Joined: Dec 11, 2004
Posts: 13410


What upload libraries are you using?
Can you post your servlet/jsp code that is handling the file upload?

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
sravanthi sri

Joined: Sep 04, 2005
Posts: 2
thanks friend

My Jsp code

<%@taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<SCRIPT LANGUAGE="JavaScript1.2">
function file1Value(thisvalue) {
thisvalue.form.file1name.value = thisvalue.form.file1.value.toString();
<%String inputPage = request.getParameter("page");%>
thisvalue.form.pagename.value = '<%=inputPage%>';
return true;
<form action = "" >
Attachment Name: <input type = "text" name = "attachname" />
<tr><td>Description :</td><td> <input type = "textarea" name = "description" /></td></tr>
<tr><td>Location :</td><td>
<INPUT TYPE="file" NAME="file1" SIZE="60" MAXLENGTH="60" onchange='return file1Value(this)'>
<INPUT TYPE="hidden" NAME="file1name" VALUE="">
<input type="hidden" name="pagename" value="" >
<td><input type = "submit" name = "submit" value= "submit" >

My code in action class

public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)throws Exception{

AttachmentForm attachform = (AttachmentForm)form;
HttpSession hsession = null;
String saveLocation = request.getParameter("file1name");"the save Location is "+saveLocation );
hsession = request.getSession();
Attachment newAttachment = new AttachmentImpl();
newAttachment.setName(request.getParameter("attachname"));"the attachment name "+request.getParameter("attachname") );
String page = request.getParameter("pagename");
Project sessionProject = (Project)hsession.getAttribute(SESSION_PROJECT);
newAttachment = ServiceLocator.instance().getPMTService().addNewAttachmentToProject(newAttachment,sessionProject,saveLocation);
Task sessionTask = (Task)hsession.getAttribute(SESSION_TASK);
newAttachment = ServiceLocator.instance().getPMTService().addNewAttachmentToTask(newAttachment,sessionTask,saveLocation);

} catch (Exception e) {
throw e;
} finally {

return mapping.findForward(TARGET);

Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Are you using Struts?
If so, you might have better luck asking this in the struts forum.
It is sorta covered in the JavaRanch Style Guide.
subject: using file chooser
Similar Threads
Uploading images with jsp
Send and Receive Binary Data in XML
Sending multiple file from an applet to the server
Is there any way to do check how many files the user have uploaded?
File Upload Error