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
Author

using file chooser

sravanthi sri
Greenhorn

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"
ENCTYPE="multipart/form-data">
<input TYPE="file" NAME="filename">
</form>

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

regards
sravanthi
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

sravanthi,

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
Greenhorn

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">
<html>
<head>
<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;
}
</SCRIPT>
</head>
<body>
<form action = "CreateUpdateAttachment.do" >
<table>
<tr>
Attachment Name: <input type = "text" name = "attachname" />
</tr>
<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>
</tr>
<tr>
<td><input type = "submit" name = "submit" value= "submit" >
</td></tr>
</table>
</form>
</body>
</html>

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");
logger.info("the save Location is "+saveLocation );
try{
hsession = request.getSession();
Attachment newAttachment = new AttachmentImpl();
newAttachment.setSaveLocation(saveLocation);
newAttachment.setName(request.getParameter("attachname"));
logger.info("the attachment name "+request.getParameter("attachname") );
newAttachment.setDescription(request.getParameter("description"));
newAttachment.setVersion(VERSION);
newAttachment.setLatestVersion(true);
String page = request.getParameter("pagename");
if(page.equals("project")){
Project sessionProject = (Project)hsession.getAttribute(SESSION_PROJECT);
newAttachment = ServiceLocator.instance().getPMTService().addNewAttachmentToProject(newAttachment,sessionProject,saveLocation);
}
if(page.equals("task")){
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);

regards
sravanthi
Ben Souther
Sheriff

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