This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using file chooser

 
sravanthi sri
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sravanthi,

What upload libraries are you using?
Can you post your servlet/jsp code that is handling the file upload?
 
sravanthi sri
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using Struts?
If so, you might have better luck asking this in the struts forum.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic