You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "uma.k" <um...@net-kraft.com> on 2004/12/18 10:40:25 UTC

file upload problem

Hi,
I am modifying the upload files given by struts and trying to upload the
file to server without the user entering any path.

I have modified the upload.jsp with
<html:text property="filePath" value="/upload/images" />

Its means I am trying to upload to the same context in which the jsp is
running (webapps/test/upload/images)

I have modified the UploadAction.java as

                //else {
                    //write the file to the file specified
                    String filePath = theForm.getFilePath();
                    System.out.println("filePath:"+filePath);
                    String fileName2 = filePath+"/"+fileName;
                    System.out.println("fileName2:"+fileName2);
                    OutputStream bos = new FileOutputStream(fileName2);
                    int bytesRead = 0;
                    byte[] buffer = new byte[8192];
                    while ((bytesRead = stream.read(buffer, 0, 8192)) != -1)
{
                        bos.write(buffer, 0, bytesRead);
                    }
                    bos.close();
                    data = "The file has been written to \"" +
theForm.getFilePath() + "\"";
                //}

I get this output too
filePath:/upload/images
fileName2:/upload/images/test.jpg

I do not have any error the page just becomes blank and the file is not
uploaded. Any ideas?

Uma


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: file upload problem

Posted by "uma.k" <um...@net-kraft.com>.
Hi Jay,
It works if I give in this way but I wanted to upload by giving relative
path. i.e. the context in which the application is working. Also if I print
                    File fileTemp = new File(fileName2);
                    System.out.println("fileTemp:
"+fileTemp.getAbsolutePath());

I get fileTemp: D:\upload\images\test.jpg which actually doesn't exist. Any
ideas on how to over come this issue?

Uma

-----Original Message-----
From: Jay Chandran [mailto:jay.chandran@iqss.co.in]
Sent: Sunday, December 19, 2004 12:59 PM
To: Struts Users Mailing List
Subject: Re: file upload problem


how is ur file path given ??/

 please try to give the full path ie like "C:\Program Files\Tomcat
5.0\webapps\cevm\uploadedimages\"

ie filePath value should be C:\Program Files\Tomcat
5.0\webapps\cevm\uploadedimages\

ie in your jsp page give something as below .

<INPUT TYPE ="hidden" NAME ="filePath" size="39" value="C:\Program
Files\Tomcat 5.0\webapps\cevm\uploadedimages\"/>

----- Original Message -----
From: "uma.k" <um...@net-kraft.com>
To: "'Struts Users Mailing List'" <us...@struts.apache.org>; "'Jay Chandran'"
<ja...@iqss.co.in>
Sent: Sunday, December 19, 2004 12:32 PM
Subject: RE: file upload problem


> Hi Jay,
> I tried this way too, but I am actually getting FileNotFoundException.
This
> is the modified code
>     String filePath = theForm.getFilePath();
>     System.out.println("filePath:"+filePath);
>     String fileName2 = filePath+fileName;
>     System.out.println("fileName2:"+fileName2);
>     //byte[] fileContent =file.getFileData();
>     OutputStream bos = new FileOutputStream(new File(fileName2));
>     int bytesRead = 0;
>     byte[] buffer = new byte[8192];
>     while ((bytesRead = stream.read(buffer, 0, 8192)) != -1) {
>           bos.write(buffer, 0, bytesRead);
>     }
>     bos.close();
>
> In the catch block I made SOP to print the exception and this is the
output
> in Tomcat console.
>
> filePath:/upload/images/
> fileName2:/upload/images/test.jpg
> fnfejava.io.FileNotFoundException: \upload\images\test.jpg (The system
> cannot
> find the path specified)
>
> Why is the system not able to find out the path?
>
> Uma
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: file upload problem

Posted by Jay Chandran <ja...@iqss.co.in>.
how is ur file path given ??/

 please try to give the full path ie like "C:\Program Files\Tomcat
5.0\webapps\cevm\uploadedimages\"

ie filePath value should be C:\Program Files\Tomcat
5.0\webapps\cevm\uploadedimages\

ie in your jsp page give something as below .

<INPUT TYPE ="hidden" NAME ="filePath" size="39" value="C:\Program
Files\Tomcat 5.0\webapps\cevm\uploadedimages\"/>

----- Original Message -----
From: "uma.k" <um...@net-kraft.com>
To: "'Struts Users Mailing List'" <us...@struts.apache.org>; "'Jay Chandran'"
<ja...@iqss.co.in>
Sent: Sunday, December 19, 2004 12:32 PM
Subject: RE: file upload problem


> Hi Jay,
> I tried this way too, but I am actually getting FileNotFoundException.
This
> is the modified code
>     String filePath = theForm.getFilePath();
>     System.out.println("filePath:"+filePath);
>     String fileName2 = filePath+fileName;
>     System.out.println("fileName2:"+fileName2);
>     //byte[] fileContent =file.getFileData();
>     OutputStream bos = new FileOutputStream(new File(fileName2));
>     int bytesRead = 0;
>     byte[] buffer = new byte[8192];
>     while ((bytesRead = stream.read(buffer, 0, 8192)) != -1) {
>           bos.write(buffer, 0, bytesRead);
>     }
>     bos.close();
>
> In the catch block I made SOP to print the exception and this is the
output
> in Tomcat console.
>
> filePath:/upload/images/
> fileName2:/upload/images/test.jpg
> fnfejava.io.FileNotFoundException: \upload\images\test.jpg (The system
> cannot
> find the path specified)
>
> Why is the system not able to find out the path?
>
> Uma
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


error in request.getAttribute

Posted by "uma.k" <um...@net-kraft.com>.
Hi,
Why do I get this error 
org.apache.jasper.compiler.ParseException: /upload/display.jsp(23,70) Attribute image_path has no value

when I use 
<html:image src="<%=request.getAttribute("image_path")%>" />

but this works fine
when I use 
<img src="<%=request.getAttribute("image_path")%>" />

Any ideas?

Uma


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: file upload problem

Posted by Dakota Jack <da...@gmail.com>.
This may be a problem, but not for that reason.  There is nothing
inconsistent between this solution and moving between different OSs. 
The questions in that case is not whether the path is absolute or
relative but whether it is OS dependent.  Those are very different
questions.

Jack


On Mon, 20 Dec 2004 11:50:01 +0530, uma.k <um...@net-kraft.com> wrote:
> NO, this might not be best solution as the folders are already existing and
> If I have to move from one OS to another OS then this would be a problem.
> So, I wanted to upload the file to relative path rather than absolute path.
> 
> Any one please?
> 
> -----Original Message-----
> From: yue pengfei [mailto:yuepengfei1978@yahoo.com.cn]
> Sent: Sunday, December 19, 2004 3:53 PM
> To: Struts Users Mailing List
> Subject: RE: file upload problem
> 
> May be you need setup the full path of your file ,as below
> File f = new File(filePath);
> f.mkdirs();
> 
> "uma.k" <um...@net-kraft.com> wrote:
> Hi Jay,
> I tried this way too, but I am actually getting FileNotFoundException. This
> is the modified code
> String filePath = theForm.getFilePath();
> System.out.println("filePath:"+filePath);
> String fileName2 = filePath+fileName;
> System.out.println("fileName2:"+fileName2);
> //byte[] fileContent =file.getFileData();
> OutputStream bos = new FileOutputStream(new File(fileName2));
> int bytesRead = 0;
> byte[] buffer = new byte[8192];
> while ((bytesRead = stream.read(buffer, 0, 8192)) != -1) {
> bos.write(buffer, 0, bytesRead);
> }
> bos.close();
> 
> In the catch block I made SOP to print the exception and this is the output
> in Tomcat console.
> 
> filePath:/upload/images/
> fileName2:/upload/images/test.jpg
> fnfejava.io.FileNotFoundException: \upload\images\test.jpg (The system
> cannot
> find the path specified)
> 
> Why is the system not able to find out the path?
> 
> Uma
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> ---------------------------------
> Do You Yahoo!?
> 150万曲MP3疯狂搜,带您闯入音乐殿堂
> 美女明星应有尽有,搜遍美图、艳图和酷图
> 1G就是1000兆,雅虎电邮自助扩容!
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


-- 
"You can lead a horse to water but you cannot make it float on its back."

~Dakota Jack~

"You can't wake a person who is pretending to be asleep."

~Native Proverb~

"Each man is good in His sight. It is not necessary for eagles to be crows."

~Hunkesni (Sitting Bull), Hunkpapa Sioux~

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: html:file value

Posted by "uma.k" <um...@net-kraft.com>.
Hi Jack,
I basically wanted the value from html:file to get it displayed in the
html:img tag in another jsp. But can you tell me if we can get the value
from the html:img tag again so that I can submit it to the db? Any example?

This doesn't work for me, I get "Attribute image_path has no value"
<b>Image path:</b><html:img src="<%=request.getAttribute("image_path")%>" />

Uma

-----Original Message-----
From: Dakota Jack [mailto:dakota.jack@gmail.com]
Sent: Monday, December 20, 2004 7:58 PM
To: Struts Users Mailing List
Subject: Re: html:file value


This is just an input type in a form, Uma, so you need some sort of
form submission which "references" an action class, usually something
like "uploadAction.do".

Jack


On Mon, 20 Dec 2004 19:38:23 +0530, uma.k <um...@net-kraft.com> wrote:
> How do I get html:file value in Action class without using javascript?
>
> <html:file property="theFile" />
>
> Uma
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


--
"You can lead a horse to water but you cannot make it float on its back."

~Dakota Jack~

"You can't wake a person who is pretending to be asleep."

~Native Proverb~

"Each man is good in His sight. It is not necessary for eagles to be crows."

~Hunkesni (Sitting Bull), Hunkpapa Sioux~

-----------------------------------------------

"This message may contain confidential and/or privileged information.
If you are not the addressee or authorized to receive this for the
addressee, you must not use, copy, disclose, or take any action based
on this message or any information herein. If you have received this
message in error, please advise the sender immediately by reply e-mail
and delete this message. Thank you for your cooperation."

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: html:file value

Posted by "uma.k" <um...@net-kraft.com>.
Hi Jack,
Thanks for the replies. I basically wanted to write a test programme where
in I have few
text fields and 3 html:file inputs. Before I send the "text" information and
"images" to the
server, I wanted to show a preview to the user.

What I am planning to do is, pass the values to the bean for "input text"
and for images
get the value that is populated using the "browse(html:file)" button to the
next JSP.
So that the user dont have to enter the image URL again and I can display
the image in
preview from his system instead of uploading it to the server.

After the preview, the user may edit or submit the data, if submitted, I
need to get the
values of the text (html:text), I feel this should not be a problem but for
the image
I need to get the info i.e. the value of html:image tag. And then do the
same as I was asking
before for creating a file in the server.

Thanks
Uma


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: html:file value

Posted by Dakota Jack <da...@gmail.com>.
This is just an input type in a form, Uma, so you need some sort of
form submission which "references" an action class, usually something
like "uploadAction.do".

Jack


On Mon, 20 Dec 2004 19:38:23 +0530, uma.k <um...@net-kraft.com> wrote:
> How do I get html:file value in Action class without using javascript?
> 
> <html:file property="theFile" />
> 
> Uma
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


-- 
"You can lead a horse to water but you cannot make it float on its back."

~Dakota Jack~

"You can't wake a person who is pretending to be asleep."

~Native Proverb~

"Each man is good in His sight. It is not necessary for eagles to be crows."

~Hunkesni (Sitting Bull), Hunkpapa Sioux~

-----------------------------------------------

"This message may contain confidential and/or privileged information.
If you are not the addressee or authorized to receive this for the
addressee, you must not use, copy, disclose, or take any action based
on this message or any information herein. If you have received this
message in error, please advise the sender immediately by reply e-mail
and delete this message. Thank you for your cooperation."

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE:[SOLVED] file upload problem

Posted by "uma.k" <um...@net-kraft.com>.
Hi Jack,
Thanks it works great. Thanks again.

Uma

-----Original Message-----
From: Dakota Jack [mailto:dakota.jack@gmail.com]
Sent: Monday, December 20, 2004 6:18 PM
To: Struts Users Mailing List
Subject: Re: file upload problem


Try this, for example:

String path =
request.getSession().getServletContext().getRealPath(java.io.File.separator)
+ upload + File.separator + images + File.separator;

There are other ways, too.

Jack




On Mon, 20 Dec 2004 16:18:00 +0530, uma.k <um...@net-kraft.com> wrote:
> Hi Sunny,
> It creates a file in "C:\Documents and Settings\uma.k\Start
> Menu\Programs\Apache Tomcat 4.0" and its path is virtual and maps to
> D:\tomc.... only. But I wanted to upload to "images" directory where my
app
> is running. e.g. "D:\Program Files\Apache Tomcat
> 4.0\webapps\test\upload\images"
>
> Here my context is "test" and my jsps are located in "upload" directory.
Any
> ideas?
>
> Uma
>
> -----Original Message-----
> From: Sunny [mailto:suneel@collab.net]
> Sent: Monday, December 20, 2004 12:21 PM
> To: Struts Users Mailing List
> Subject: Re: file upload problem
>
> JSP:
> <%@ 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"%>
>
> <html:html xhtml = "true">
> <html:form action = "uploadFile" enctype = "multipart/form-data" >
> <html:file property = "file2Upload" />
> <html:submit>Upload</html:submit>
> </html:form>
> </html:html>
> =========================
> struts-config.xml:
>
> <form-bean name = "FileUploadForm" *type=
> "org.apache.struts.validator.DynaValidatorForm" *>
> <form-property name="file2Upload"
type="org.apache.struts.upload.FormFile"/>
> </form-bean>
>
> ....
>
> <action path = "/uploadFile" name = "FileUploadForm"
> type = "mypackage.UploadAction"
> input = "/mywebapp/uploadFile.jsp"
> scope = "request"
> validate = "false">
> <forward name = "success" path = "/mywebapp/uploadFile.jsp"/>
> </action>
>
> ==========================
> Action: (execute(..) method)
>
> DynaValidatorForm uploadForm = (DynaValidatorForm)form;
> FormFile uploadedFile= (FormFile)uploadForm.get("file2Upload");
> byte[] fileData = uploadedFile.getFileData();
> String fileName = uploadedFile.getFileName();
>
> //NOW YOU have to write code to create a File object and write to it.
>
> try {
> File serverFile = new File(fileName); // Here you should specify the path
> serverFile.createNewFile();
> FileOutputStream os = new FileOutputStream(serverFile);
> os.write(fileData);
> os.close();
> }
> catch(Exception ex) {
> System.out.println("ERROR::::::: " + ex);
> }
>
> ============================
>
> uma.k wrote:
>
> >NO, this might not be best solution as the folders are already existing
and
> >If I have to move from one OS to another OS then this would be a problem.
> >So, I wanted to upload the file to relative path rather than absolute
path.
> >
> >Any one please?
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


--
"You can lead a horse to water but you cannot make it float on its back."

~Dakota Jack~

"You can't wake a person who is pretending to be asleep."

~Native Proverb~

"Each man is good in His sight. It is not necessary for eagles to be crows."

~Hunkesni (Sitting Bull), Hunkpapa Sioux~

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


html:file value

Posted by "uma.k" <um...@net-kraft.com>.
How do I get html:file value in Action class without using javascript?

<html:file property="theFile" />

Uma

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: file upload problem

Posted by Dakota Jack <da...@gmail.com>.
Try this, for example:

String path = request.getSession().getServletContext().getRealPath(java.io.File.separator)
+ upload + File.separator + images + File.separator;

There are other ways, too.

Jack




On Mon, 20 Dec 2004 16:18:00 +0530, uma.k <um...@net-kraft.com> wrote:
> Hi Sunny,
> It creates a file in "C:\Documents and Settings\uma.k\Start
> Menu\Programs\Apache Tomcat 4.0" and its path is virtual and maps to
> D:\tomc.... only. But I wanted to upload to "images" directory where my app
> is running. e.g. "D:\Program Files\Apache Tomcat
> 4.0\webapps\test\upload\images"
> 
> Here my context is "test" and my jsps are located in "upload" directory. Any
> ideas?
> 
> Uma
> 
> -----Original Message-----
> From: Sunny [mailto:suneel@collab.net]
> Sent: Monday, December 20, 2004 12:21 PM
> To: Struts Users Mailing List
> Subject: Re: file upload problem
> 
> JSP:
> <%@ 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"%>
> 
> <html:html xhtml = "true">
> <html:form action = "uploadFile" enctype = "multipart/form-data" >
> <html:file property = "file2Upload" />
> <html:submit>Upload</html:submit>
> </html:form>
> </html:html>
> =========================
> struts-config.xml:
> 
> <form-bean name = "FileUploadForm" *type=
> "org.apache.struts.validator.DynaValidatorForm" *>
> <form-property name="file2Upload" type="org.apache.struts.upload.FormFile"/>
> </form-bean>
> 
> ....
> 
> <action path = "/uploadFile" name = "FileUploadForm"
> type = "mypackage.UploadAction"
> input = "/mywebapp/uploadFile.jsp"
> scope = "request"
> validate = "false">
> <forward name = "success" path = "/mywebapp/uploadFile.jsp"/>
> </action>
> 
> ==========================
> Action: (execute(..) method)
> 
> DynaValidatorForm uploadForm = (DynaValidatorForm)form;
> FormFile uploadedFile= (FormFile)uploadForm.get("file2Upload");
> byte[] fileData = uploadedFile.getFileData();
> String fileName = uploadedFile.getFileName();
> 
> //NOW YOU have to write code to create a File object and write to it.
> 
> try {
> File serverFile = new File(fileName); // Here you should specify the path
> serverFile.createNewFile();
> FileOutputStream os = new FileOutputStream(serverFile);
> os.write(fileData);
> os.close();
> }
> catch(Exception ex) {
> System.out.println("ERROR::::::: " + ex);
> }
> 
> ============================
> 
> uma.k wrote:
> 
> >NO, this might not be best solution as the folders are already existing and
> >If I have to move from one OS to another OS then this would be a problem.
> >So, I wanted to upload the file to relative path rather than absolute path.
> >
> >Any one please?
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


-- 
"You can lead a horse to water but you cannot make it float on its back."

~Dakota Jack~

"You can't wake a person who is pretending to be asleep."

~Native Proverb~

"Each man is good in His sight. It is not necessary for eagles to be crows."

~Hunkesni (Sitting Bull), Hunkpapa Sioux~

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Passing information to Action class

Posted by Dakota Jack <da...@gmail.com>.
Don't use a form and check the request object for what happens to be
in the critter, just as you suggested.  What is the problem?

Jack

-- 
"You can lead a horse to water but you cannot make it float on its back."

~Dakota Jack~

"You can't wake a person who is pretending to be asleep."

~Native Proverb~

"Each man is good in His sight. It is not necessary for eagles to be crows."

~Hunkesni (Sitting Bull), Hunkpapa Sioux~

-----------------------------------------------

"This message may contain confidential and/or privileged information.
If you are not the addressee or authorized to receive this for the
addressee, you must not use, copy, disclose, or take any action based
on this message or any information herein. If you have received this
message in error, please advise the sender immediately by reply e-mail
and delete this message. Thank you for your cooperation."

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Passing information to Action class

Posted by "uma.k" <um...@net-kraft.com>.
Yes Jack, You are right. I have ActionForm but do not want to use it.

-----Original Message-----
From: Dakota Jack [mailto:dakota.jack@gmail.com]
Sent: Wednesday, December 22, 2004 10:56 AM
To: Struts Users Mailing List; Shiva Narayana
Subject: Re: Passing information to Action class


I may be wrong, Shiva, but I think she wants to avoid the use of
action forms in this case rather than avoid writing classes.  If you
use forms in a file upload, then you are trapped into using the Struts
file upload implementation.  She may, I don't know, want to avoid
that.

Jack



--
"You can lead a horse to water but you cannot make it float on its back."

~Dakota Jack~

"You can't wake a person who is pretending to be asleep."

~Native Proverb~

"Each man is good in His sight. It is not necessary for eagles to be crows."

~Hunkesni (Sitting Bull), Hunkpapa Sioux~

-----------------------------------------------

"This message may contain confidential and/or privileged information.
If you are not the addressee or authorized to receive this for the
addressee, you must not use, copy, disclose, or take any action based
on this message or any information herein. If you have received this
message in error, please advise the sender immediately by reply e-mail
and delete this message. Thank you for your cooperation."

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Passing information to Action class

Posted by Dakota Jack <da...@gmail.com>.
I may be wrong, Shiva, but I think she wants to avoid the use of
action forms in this case rather than avoid writing classes.  If you
use forms in a file upload, then you are trapped into using the Struts
file upload implementation.  She may, I don't know, want to avoid
that.

Jack



-- 
"You can lead a horse to water but you cannot make it float on its back."

~Dakota Jack~

"You can't wake a person who is pretending to be asleep."

~Native Proverb~

"Each man is good in His sight. It is not necessary for eagles to be crows."

~Hunkesni (Sitting Bull), Hunkpapa Sioux~

-----------------------------------------------

"This message may contain confidential and/or privileged information.
If you are not the addressee or authorized to receive this for the
addressee, you must not use, copy, disclose, or take any action based
on this message or any information herein. If you have received this
message in error, please advise the sender immediately by reply e-mail
and delete this message. Thank you for your cooperation."

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Passing information to Action class

Posted by Shiva Narayana <sh...@gmail.com>.
try with DynaActionForm it solves ur problem. No noeed to write FormBean

<form-bean name="simpleForm" type="org.apache.struts.action.DynaActionForm">
<form-property name="fileAbsPath" type="java.lang.String"/>
</form-bean>


On Tue, 21 Dec 2004 19:16:50 +0530, uma.k <um...@net-kraft.com> wrote:
> Hi,
> How to pass information to Action class directly? i.e. I don't want to write
> a ActionForm class.
> 
> <html:form action="editUpload.do">
> <html:hidden property="fileAbsPath" value="<%=fileAbsPath%>" />
> <html:submit>Edit</html:submit>
> </html:form>
> 
> And my struts-config.xml will look like this
> 
>    <action
>                path="/editUpload"
>                type="upload.EditUploadAction"
>                scope="request"
>                input="/upload/display.jsp">
>      <forward name="success" path="/upload/upload.jsp" />
>    </action>
> 
> in my .java execute method, I am writing
> String theFile = request.getParameter("fileAbsPath");
> 
> Any ideas?
> 
> Uma
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


-- 
Regards
Shiva

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: file upload problem

Posted by "uma.k" <um...@net-kraft.com>.
Hi Sunny,
It creates a file in "C:\Documents and Settings\uma.k\Start
Menu\Programs\Apache Tomcat 4.0" and its path is virtual and maps to
D:\tomc.... only. But I wanted to upload to "images" directory where my app
is running. e.g. "D:\Program Files\Apache Tomcat
4.0\webapps\test\upload\images"

Here my context is "test" and my jsps are located in "upload" directory. Any
ideas?

Uma

-----Original Message-----
From: Sunny [mailto:suneel@collab.net]
Sent: Monday, December 20, 2004 12:21 PM
To: Struts Users Mailing List
Subject: Re: file upload problem



JSP:
<%@ 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"%>

<html:html xhtml = "true">
<html:form action = "uploadFile" enctype = "multipart/form-data" >
<html:file property = "file2Upload" />
<html:submit>Upload</html:submit>
</html:form>
</html:html>
=========================
struts-config.xml:

<form-bean name = "FileUploadForm" *type=
"org.apache.struts.validator.DynaValidatorForm" *>
<form-property name="file2Upload" type="org.apache.struts.upload.FormFile"/>
</form-bean>

....

<action path = "/uploadFile" name = "FileUploadForm"
type = "mypackage.UploadAction"
input = "/mywebapp/uploadFile.jsp"
scope = "request"
validate = "false">
<forward name = "success" path = "/mywebapp/uploadFile.jsp"/>
</action>

==========================
Action: (execute(..) method)

DynaValidatorForm uploadForm = (DynaValidatorForm)form;
FormFile uploadedFile= (FormFile)uploadForm.get("file2Upload");
byte[] fileData = uploadedFile.getFileData();
String fileName = uploadedFile.getFileName();

//NOW YOU have to write code to create a File object and write to it.

try {
File serverFile = new File(fileName); // Here you should specify the path
serverFile.createNewFile();
FileOutputStream os = new FileOutputStream(serverFile);
os.write(fileData);
os.close();
}
catch(Exception ex) {
System.out.println("ERROR::::::: " + ex);
}


============================














uma.k wrote:

>NO, this might not be best solution as the folders are already existing and
>If I have to move from one OS to another OS then this would be a problem.
>So, I wanted to upload the file to relative path rather than absolute path.
>
>Any one please?
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: file upload problem

Posted by "uma.k" <um...@net-kraft.com>.
Hi Sunny,
Thanks for the reply. I will try it out and get back.

Thanks
Uma

-----Original Message-----
From: Sunny [mailto:suneel@collab.net]
Sent: Monday, December 20, 2004 12:21 PM
To: Struts Users Mailing List
Subject: Re: file upload problem



JSP:
<%@ 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"%>

<html:html xhtml = "true">
<html:form action = "uploadFile" enctype = "multipart/form-data" >
<html:file property = "file2Upload" />
<html:submit>Upload</html:submit>
</html:form>
</html:html>
=========================
struts-config.xml:

<form-bean name = "FileUploadForm" *type=
"org.apache.struts.validator.DynaValidatorForm" *>
<form-property name="file2Upload" type="org.apache.struts.upload.FormFile"/>
</form-bean>

....

<action path = "/uploadFile" name = "FileUploadForm"
type = "mypackage.UploadAction"
input = "/mywebapp/uploadFile.jsp"
scope = "request"
validate = "false">
<forward name = "success" path = "/mywebapp/uploadFile.jsp"/>
</action>

==========================
Action: (execute(..) method)

DynaValidatorForm uploadForm = (DynaValidatorForm)form;
FormFile uploadedFile= (FormFile)uploadForm.get("file2Upload");
byte[] fileData = uploadedFile.getFileData();
String fileName = uploadedFile.getFileName();

//NOW YOU have to write code to create a File object and write to it.

try {
File serverFile = new File(fileName); // Here you should specify the path
serverFile.createNewFile();
FileOutputStream os = new FileOutputStream(serverFile);
os.write(fileData);
os.close();
}
catch(Exception ex) {
System.out.println("ERROR::::::: " + ex);
}


============================














uma.k wrote:

>NO, this might not be best solution as the folders are already existing and
>If I have to move from one OS to another OS then this would be a problem.
>So, I wanted to upload the file to relative path rather than absolute path.
>
>Any one please?
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to implement torque?

Posted by Jay Chandran <ja...@iqss.co.in>.
Thanks Eddie

I will do that. Have u tried implementing the same? :)

Jay Chandran.


----- Original Message -----
From: "Eddie Bush" <ea...@gmail.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>; "Jay Chandran"
<ja...@iqss.co.in>
Sent: Wednesday, December 22, 2004 11:32 AM
Subject: Re: How to implement torque?


> Have you tried surfing the Torque site for docs?  They used to have
> some decent docs ... been ages since I looked at it though.
>
> I believe they have a user list there - for Turbine, if not Torque.
> That is likely a better spot to ask than here.
>
> On Wed, 22 Dec 2004 11:32:26 +0530, Jay Chandran
> <ja...@iqss.co.in> wrote:
> > Does any one knows how to implement TORQUE in an existing system
implemented
> > using struts and postgreSQL.
> >
> > :(
> >
> > Jay Chandran
>
> --
> Eddie Bush
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to implement torque?

Posted by Eddie Bush <ea...@gmail.com>.
Have you tried surfing the Torque site for docs?  They used to have
some decent docs ... been ages since I looked at it though.

I believe they have a user list there - for Turbine, if not Torque. 
That is likely a better spot to ask than here.

On Wed, 22 Dec 2004 11:32:26 +0530, Jay Chandran
<ja...@iqss.co.in> wrote:
> Does any one knows how to implement TORQUE in an existing system implemented
> using struts and postgreSQL.
> 
> :(
> 
> Jay Chandran

-- 
Eddie Bush

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


How to implement torque?

Posted by Jay Chandran <ja...@iqss.co.in>.
Does any one knows how to implement TORQUE in an existing system implemented
using struts and postgreSQL.

:(


Jay Chandran



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Passing information to Action class

Posted by Jay Chandran <ja...@iqss.co.in>.
Below is used using vm(velovity templates) as front end .Here using
addQueryData we are passing parameter which can be accessed in the action
file.


<a
href='$link.setAction("deleteuser_vm").addQueryData("userName",Devan)'>Delet
e</a>


in my .java execute method, write
> String user= request.getParameter("userName");


Check the command in jsp for adding parameter to the link action file.

----- Original Message -----
From: "uma.k" <um...@net-kraft.com>
To: "'Struts Users Mailing List'" <us...@struts.apache.org>
Sent: Tuesday, December 21, 2004 7:16 PM
Subject: Passing information to Action class


> Hi,
> How to pass information to Action class directly? i.e. I don't want to
write
> a ActionForm class.
>
> <html:form action="editUpload.do">
> <html:hidden property="fileAbsPath" value="<%=fileAbsPath%>" />
> <html:submit>Edit</html:submit>
> </html:form>
>
> And my struts-config.xml will look like this
>
>     <action
>     path="/editUpload"
>     type="upload.EditUploadAction"
>     scope="request"
>     input="/upload/display.jsp">
>       <forward name="success" path="/upload/upload.jsp" />
>     </action>
>
> in my .java execute method, I am writing
> String theFile = request.getParameter("fileAbsPath");
>
> Any ideas?
>
> Uma
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Passing information to Action class

Posted by "uma.k" <um...@net-kraft.com>.
Hi,
How to pass information to Action class directly? i.e. I don't want to write
a ActionForm class.

<html:form action="editUpload.do">
<html:hidden property="fileAbsPath" value="<%=fileAbsPath%>" />
<html:submit>Edit</html:submit>
</html:form>

And my struts-config.xml will look like this

    <action
    		path="/editUpload"
    		type="upload.EditUploadAction"
    		scope="request"
    		input="/upload/display.jsp">
      <forward name="success" path="/upload/upload.jsp" />
    </action>

in my .java execute method, I am writing
String theFile = request.getParameter("fileAbsPath");

Any ideas?

Uma


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: file upload problem

Posted by Sunny <su...@collab.net>.
JSP:
<%@ 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"%>

<html:html xhtml = "true">
<html:form action = "uploadFile" enctype = "multipart/form-data" >
<html:file property = "file2Upload" />
<html:submit>Upload</html:submit>
</html:form>
</html:html>
=========================
struts-config.xml:

<form-bean name = "FileUploadForm" *type=
"org.apache.struts.validator.DynaValidatorForm" *>
<form-property name="file2Upload" type="org.apache.struts.upload.FormFile"/>
</form-bean>

....

<action path = "/uploadFile" name = "FileUploadForm"
type = "mypackage.UploadAction"
input = "/mywebapp/uploadFile.jsp"
scope = "request"
validate = "false">
<forward name = "success" path = "/mywebapp/uploadFile.jsp"/>
</action>

==========================
Action: (execute(..) method)

DynaValidatorForm uploadForm = (DynaValidatorForm)form;
FormFile uploadedFile= (FormFile)uploadForm.get("file2Upload");
byte[] fileData = uploadedFile.getFileData();
String fileName = uploadedFile.getFileName();

//NOW YOU have to write code to create a File object and write to it.

try {
File serverFile = new File(fileName); // Here you should specify the path
serverFile.createNewFile();
FileOutputStream os = new FileOutputStream(serverFile);
os.write(fileData);
os.close();
}
catch(Exception ex) {
System.out.println("ERROR::::::: " + ex);
}


============================














uma.k wrote:

>NO, this might not be best solution as the folders are already existing and
>If I have to move from one OS to another OS then this would be a problem.
>So, I wanted to upload the file to relative path rather than absolute path.
>
>Any one please?
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: file upload problem

Posted by "uma.k" <um...@net-kraft.com>.
NO, this might not be best solution as the folders are already existing and
If I have to move from one OS to another OS then this would be a problem.
So, I wanted to upload the file to relative path rather than absolute path.

Any one please?

-----Original Message-----
From: yue pengfei [mailto:yuepengfei1978@yahoo.com.cn]
Sent: Sunday, December 19, 2004 3:53 PM
To: Struts Users Mailing List
Subject: RE: file upload problem


May be you need setup the full path of your file ,as below
File f = new File(filePath);
f.mkdirs();


"uma.k" <um...@net-kraft.com> wrote:
Hi Jay,
I tried this way too, but I am actually getting FileNotFoundException. This
is the modified code
String filePath = theForm.getFilePath();
System.out.println("filePath:"+filePath);
String fileName2 = filePath+fileName;
System.out.println("fileName2:"+fileName2);
//byte[] fileContent =file.getFileData();
OutputStream bos = new FileOutputStream(new File(fileName2));
int bytesRead = 0;
byte[] buffer = new byte[8192];
while ((bytesRead = stream.read(buffer, 0, 8192)) != -1) {
bos.write(buffer, 0, bytesRead);
}
bos.close();

In the catch block I made SOP to print the exception and this is the output
in Tomcat console.

filePath:/upload/images/
fileName2:/upload/images/test.jpg
fnfejava.io.FileNotFoundException: \upload\images\test.jpg (The system
cannot
find the path specified)

Why is the system not able to find out the path?

Uma


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org




---------------------------------
Do You Yahoo!?
150万曲MP3疯狂搜,带您闯入音乐殿堂
美女明星应有尽有,搜遍美图、艳图和酷图
1G就是1000兆,雅虎电邮自助扩容!


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: file upload problem

Posted by yue pengfei <yu...@yahoo.com.cn>.
May be you need setup the full path of your file ,as below
File f = new File(filePath);
f.mkdirs();


"uma.k" <um...@net-kraft.com> wrote:
Hi Jay,
I tried this way too, but I am actually getting FileNotFoundException. This
is the modified code
String filePath = theForm.getFilePath();
System.out.println("filePath:"+filePath);
String fileName2 = filePath+fileName;
System.out.println("fileName2:"+fileName2);
//byte[] fileContent =file.getFileData();
OutputStream bos = new FileOutputStream(new File(fileName2));
int bytesRead = 0;
byte[] buffer = new byte[8192];
while ((bytesRead = stream.read(buffer, 0, 8192)) != -1) {
bos.write(buffer, 0, bytesRead);
}
bos.close();

In the catch block I made SOP to print the exception and this is the output
in Tomcat console.

filePath:/upload/images/
fileName2:/upload/images/test.jpg
fnfejava.io.FileNotFoundException: \upload\images\test.jpg (The system
cannot
find the path specified)

Why is the system not able to find out the path?

Uma


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org




---------------------------------
Do You Yahoo!?
150万曲MP3疯狂搜,带您闯入音乐殿堂
美女明星应有尽有,搜遍美图、艳图和酷图
1G就是1000兆,雅虎电邮自助扩容!

RE: file upload problem

Posted by "uma.k" <um...@net-kraft.com>.
Hi Jay,
I tried this way too, but I am actually getting FileNotFoundException. This
is the modified code
    String filePath = theForm.getFilePath();
    System.out.println("filePath:"+filePath);
    String fileName2 = filePath+fileName;
    System.out.println("fileName2:"+fileName2);
    //byte[] fileContent =file.getFileData();
    OutputStream bos = new FileOutputStream(new File(fileName2));
    int bytesRead = 0;
    byte[] buffer = new byte[8192];
    while ((bytesRead = stream.read(buffer, 0, 8192)) != -1) {
          bos.write(buffer, 0, bytesRead);
    }
    bos.close();

In the catch block I made SOP to print the exception and this is the output
in Tomcat console.

filePath:/upload/images/
fileName2:/upload/images/test.jpg
fnfejava.io.FileNotFoundException: \upload\images\test.jpg (The system
cannot
find the path specified)

Why is the system not able to find out the path?

Uma


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: file upload problem

Posted by Jay Chandran <ja...@iqss.co.in>.
change the below line  of ur action file
    String fileName2 = filePath+"/"+fileName;
to
String fileName2 = filePath+fileName;


----- Original Message -----
From: "uma.k" <um...@net-kraft.com>
To: "'Struts Users Mailing List'" <us...@struts.apache.org>; "'Jay Chandran'"
<ja...@iqss.co.in>
Sent: Saturday, December 18, 2004 3:44 PM
Subject: RE: file upload problem


> I get an error
> "org.apache.jasper.compiler.CompileException: /upload/upload.jsp(32,4)
> Attribute enctype invalid according to the specified TLD"
>
> I am already using  enctype in the <html:form> But when I hard code the
> value to system path e.g. c:\\test\\mages then it works but I dont want
> this. As I need to upload the file to the server.
>
> Any ideas?
>
> -----Original Message-----
> From: Jay Chandran [mailto:jay.chandran@iqss.co.in]
> Sent: Saturday, December 18, 2004 3:57 PM
> To: Struts Users Mailing List
> Subject: Re: file upload problem
>
>
> include the below and check
>
> <html:text property="filePath" value="/upload/images"
> enctype="multipart/form-data"/>
>
>
>   ----- Original Message -----
> From: "uma.k" <um...@net-kraft.com>
> To: "'Struts Users Mailing List'" <us...@struts.apache.org>
> Sent: Saturday, December 18, 2004 3:10 PM
> Subject: file upload problem
>
>
> > Hi,
> > I am modifying the upload files given by struts and trying to upload the
> > file to server without the user entering any path.
> >
> > I have modified the upload.jsp with
> > <html:text property="filePath" value="/upload/images" />
> >
> > Its means I am trying to upload to the same context in which the jsp is
> > running (webapps/test/upload/images)
> >
> > I have modified the UploadAction.java as
> >
> >                 //else {
> >                     //write the file to the file specified
> >                     String filePath = theForm.getFilePath();
> >                     System.out.println("filePath:"+filePath);
> >                     String fileName2 = filePath+"/"+fileName;
> >                     System.out.println("fileName2:"+fileName2);
> >                     OutputStream bos = new FileOutputStream(fileName2);
> >                     int bytesRead = 0;
> >                     byte[] buffer = new byte[8192];
> >                     while ((bytesRead = stream.read(buffer, 0, 8192))
> != -1)
> > {
> >                         bos.write(buffer, 0, bytesRead);
> >                     }
> >                     bos.close();
> >                     data = "The file has been written to \"" +
> > theForm.getFilePath() + "\"";
> >                 //}
> >
> > I get this output too
> > filePath:/upload/images
> > fileName2:/upload/images/test.jpg
> >
> > I do not have any error the page just becomes blank and the file is not
> > uploaded. Any ideas?
> >
> > Uma
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: file upload problem

Posted by "uma.k" <um...@net-kraft.com>.
I get an error
"org.apache.jasper.compiler.CompileException: /upload/upload.jsp(32,4)
Attribute enctype invalid according to the specified TLD"

I am already using  enctype in the <html:form> But when I hard code the
value to system path e.g. c:\\test\\mages then it works but I dont want
this. As I need to upload the file to the server.

Any ideas?

-----Original Message-----
From: Jay Chandran [mailto:jay.chandran@iqss.co.in]
Sent: Saturday, December 18, 2004 3:57 PM
To: Struts Users Mailing List
Subject: Re: file upload problem


include the below and check

<html:text property="filePath" value="/upload/images"
enctype="multipart/form-data"/>


  ----- Original Message -----
From: "uma.k" <um...@net-kraft.com>
To: "'Struts Users Mailing List'" <us...@struts.apache.org>
Sent: Saturday, December 18, 2004 3:10 PM
Subject: file upload problem


> Hi,
> I am modifying the upload files given by struts and trying to upload the
> file to server without the user entering any path.
>
> I have modified the upload.jsp with
> <html:text property="filePath" value="/upload/images" />
>
> Its means I am trying to upload to the same context in which the jsp is
> running (webapps/test/upload/images)
>
> I have modified the UploadAction.java as
>
>                 //else {
>                     //write the file to the file specified
>                     String filePath = theForm.getFilePath();
>                     System.out.println("filePath:"+filePath);
>                     String fileName2 = filePath+"/"+fileName;
>                     System.out.println("fileName2:"+fileName2);
>                     OutputStream bos = new FileOutputStream(fileName2);
>                     int bytesRead = 0;
>                     byte[] buffer = new byte[8192];
>                     while ((bytesRead = stream.read(buffer, 0, 8192))
!= -1)
> {
>                         bos.write(buffer, 0, bytesRead);
>                     }
>                     bos.close();
>                     data = "The file has been written to \"" +
> theForm.getFilePath() + "\"";
>                 //}
>
> I get this output too
> filePath:/upload/images
> fileName2:/upload/images/test.jpg
>
> I do not have any error the page just becomes blank and the file is not
> uploaded. Any ideas?
>
> Uma
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: file upload problem

Posted by Jay Chandran <ja...@iqss.co.in>.
include the below and check

<html:text property="filePath" value="/upload/images"
enctype="multipart/form-data"/>


  ----- Original Message -----
From: "uma.k" <um...@net-kraft.com>
To: "'Struts Users Mailing List'" <us...@struts.apache.org>
Sent: Saturday, December 18, 2004 3:10 PM
Subject: file upload problem


> Hi,
> I am modifying the upload files given by struts and trying to upload the
> file to server without the user entering any path.
>
> I have modified the upload.jsp with
> <html:text property="filePath" value="/upload/images" />
>
> Its means I am trying to upload to the same context in which the jsp is
> running (webapps/test/upload/images)
>
> I have modified the UploadAction.java as
>
>                 //else {
>                     //write the file to the file specified
>                     String filePath = theForm.getFilePath();
>                     System.out.println("filePath:"+filePath);
>                     String fileName2 = filePath+"/"+fileName;
>                     System.out.println("fileName2:"+fileName2);
>                     OutputStream bos = new FileOutputStream(fileName2);
>                     int bytesRead = 0;
>                     byte[] buffer = new byte[8192];
>                     while ((bytesRead = stream.read(buffer, 0, 8192))
!= -1)
> {
>                         bos.write(buffer, 0, bytesRead);
>                     }
>                     bos.close();
>                     data = "The file has been written to \"" +
> theForm.getFilePath() + "\"";
>                 //}
>
> I get this output too
> filePath:/upload/images
> fileName2:/upload/images/test.jpg
>
> I do not have any error the page just becomes blank and the file is not
> uploaded. Any ideas?
>
> Uma
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org