RE: File Upload Problem.

2001-11-29 Thread Marli Satyadi


Hi Jon,

I am trying to do file upload programatically, not using the browser and I want
to use the struts file upload library to achieve this.

So I want to try the library first by writing a simple html file and a simple
servlet for testing.
Does this mean that I cannot use the upload code if I don't use struts tags ??

Thanks.
Marli.



At 09:42 AM 11/29/2001 +, Jon.Ridgway wrote:
>Hi Marli,
>
>I might be missing something here, but you don't appear to be using struts.
>Are you aware that there is a strurs tag for file upload? Have a look at the
>struts examples.
>
>Jon.
>
>-----Original Message-
>From: Marli Satyadi [mailto:[EMAIL PROTECTED]]
>Sent: 29 November 2001 01:23
>To: [EMAIL PROTECTED]
>Subject: File Upload Problem.
>
>Hello,
>
>I was writing some upload code to test the use of  MultipartIterator class.
>
>My html code is as follows:
>-
>
> MULTIPART TEST
>ACTION="/MDC/servlet/servlet/com.cisco.nm.callhome.servlet.TestServlet"
>ENCTYPE='multipart/form-data' METHOD="POST">
>
>CLASS: 
>
>COMMAND: 
>
>DATA (XML): 
>
>File Location: 
>
>
>
>
>
>
>
>My servlet code is as follows:
>---
>  protected void doPost(HttpServletRequest req, HttpServletResponse
>resp)
>  throws ServletException, java.io.IOException
>  {
>   LogUtil.debug(_Class, " -> DO POST");
>   MultipartIterator iter = new MultipartIterator(req, 64*1024,
>Integer.MAX_VALUE, "C:/Temp");
>
>   MultipartElement elem = null;
>   while( (elem = iter.getNextElement()) != null )
>   {
>  if( elem.isFile() )
>  {
> System.out.println("ELEM is a file");
> System.out.println("FILENAME = " + elem.getFileName());
> System.out.println("FILE PATH = " +
>elem.getFile().getAbsolutePath());
>  }
>  else {
> System.out.print("NAME = '" + elem.getName() + "'");
> System.out.println(". VALUE = '" + elem.getValue() +
>"'");
> //System.out.println(elem.getName() + " = " +
>elem.getValue());
>  }
>   }
>
>  }
>
>When I use my browser to the html file, put some data in the "dataParam"
>text area and
>hit Submit,  I got the following result in Tomcat stdout.log
>
>NAME = 'class'. VALUE = 'File'
>NAME = 'cmd'. VALUE = 'Add'
>'sword>bejo1663eb7d56063ec67f23be
>ELEM is a file
>FILENAME = ch-p506-2_enable_callhome.cfg
>FILE PATH = C:\Temp\strts4674.tmp
>NAME = 'SUBMIT'. VALUE = 'Submit Query'
>
>My question is:
>--
>* Is there an explanation on why the "dataParam" parameter is not printed
>out,
>or printed out but has the wrong value ?
>* I also have written a Java multipart writer to test it, but it looks like
>that the file is always
>larger by 2 bytes. Isn't the format for multipart request like this:
>--Boundary\r\n
>content-disposition: form-data; name="blah"; filename="file.txt"\r\n
>Content-type: application/octet-stream\r\n
> \r\n
> Body goes here..
>--Boundary--\r\n
>Am I correct about the CRLF (\r\n) ? I have read RFC 1867 and RFC 2046
>and it looks correct.
>Any ideas ?
>
>Thanks in advance.
>Marli.
>
>
>--
>To unsubscribe, e-mail:
><mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail:
><mailto:[EMAIL PROTECTED]>
>
>--
>To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: File Upload Problem.

2001-11-29 Thread Marli Satyadi

Hi Mike, I tested both with IE 6.0 and Netscape 4.5.
Both give the same problem.

Any idea whether I'm sending the CRLF correctly ?

Thanks.
Marli.


At 07:49 AM 11/29/2001 -0800, SCHACHTER,MICHAEL (HP-NewJersey,ex2) wrote:
>Hi,
>
>What browser are you using to submit the form? Also,
>you may already be aware, but as mentioned by the
>other reply there's an easy way to handle multipart
>form data in Struts, you can check out the struts-upload
>webapp in the distribution for an example.
>
>As with your use of MultipartIterator, I'm not sure what
>the problem could be there.
>
>-Original Message-
>From: Marli Satyadi [mailto:[EMAIL PROTECTED]]
>Sent: Wednesday, November 28, 2001 8:23 PM
>To: [EMAIL PROTECTED]
>Subject: File Upload Problem.
>
>
>Hello,
>
>I was writing some upload code to test the use of  MultipartIterator class.
>
>My html code is as follows:
>-
>
> MULTIPART TEST
>ACTION="/MDC/servlet/servlet/com.cisco.nm.callhome.servlet.TestServlet"
>ENCTYPE='multipart/form-data' METHOD="POST">
>
>CLASS: 
>
>COMMAND: 
>
>DATA (XML): 
>
>File Location: 
>
>
>
>
>
>
>
>My servlet code is as follows:
>---
>  protected void doPost(HttpServletRequest req, HttpServletResponse
>resp)
>  throws ServletException, java.io.IOException
>  {
>   LogUtil.debug(_Class, " -> DO POST");
>   MultipartIterator iter = new MultipartIterator(req, 64*1024,
>Integer.MAX_VALUE, "C:/Temp");
>
>   MultipartElement elem = null;
>   while( (elem = iter.getNextElement()) != null )
>   {
>  if( elem.isFile() )
>  {
> System.out.println("ELEM is a file");
> System.out.println("FILENAME = " + elem.getFileName());
> System.out.println("FILE PATH = " +
>elem.getFile().getAbsolutePath());
>  }
>  else {
> System.out.print("NAME = '" + elem.getName() + "'");
> System.out.println(". VALUE = '" + elem.getValue() +
>"'");
> //System.out.println(elem.getName() + " = " +
>elem.getValue());
>  }
>   }
>
>  }
>
>When I use my browser to the html file, put some data in the "dataParam"
>text area and
>hit Submit,  I got the following result in Tomcat stdout.log
>
>NAME = 'class'. VALUE = 'File'
>NAME = 'cmd'. VALUE = 'Add'
>'sword>bejo1663eb7d56063ec67f23be
>ELEM is a file
>FILENAME = ch-p506-2_enable_callhome.cfg
>FILE PATH = C:\Temp\strts4674.tmp
>NAME = 'SUBMIT'. VALUE = 'Submit Query'
>
>My question is:
>--
>* Is there an explanation on why the "dataParam" parameter is not printed
>out,
>or printed out but has the wrong value ?
>* I also have written a Java multipart writer to test it, but it looks like
>that the file is always
>larger by 2 bytes. Isn't the format for multipart request like this:
>--Boundary\r\n
>content-disposition: form-data; name="blah"; filename="file.txt"\r\n
>Content-type: application/octet-stream\r\n
> \r\n
> Body goes here..
>--Boundary--\r\n
>Am I correct about the CRLF (\r\n) ? I have read RFC 1867 and RFC 2046
>and it looks correct.
>Any ideas ?
>
>Thanks in advance.
>Marli.
>
>
>--
>To unsubscribe, e-mail:
><mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail:
><mailto:[EMAIL PROTECTED]>
>
>--
>To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




File Upload Problem.

2001-11-28 Thread Marli Satyadi

Hello,

I was writing some upload code to test the use of  MultipartIterator class.

My html code is as follows:
-

 MULTIPART TEST


CLASS: 

COMMAND: 

DATA (XML): 

File Location: 







My servlet code is as follows:
---
 protected void doPost(HttpServletRequest req, HttpServletResponse 
resp)
 throws ServletException, java.io.IOException
 {
  LogUtil.debug(_Class, " -> DO POST");
  MultipartIterator iter = new MultipartIterator(req, 64*1024, 
Integer.MAX_VALUE, "C:/Temp");

  MultipartElement elem = null;
  while( (elem = iter.getNextElement()) != null )
  {
 if( elem.isFile() )
 {
System.out.println("ELEM is a file");
System.out.println("FILENAME = " + elem.getFileName());
System.out.println("FILE PATH = " + 
elem.getFile().getAbsolutePath());
 }
 else {
System.out.print("NAME = '" + elem.getName() + "'");
System.out.println(". VALUE = '" + elem.getValue() + "'");
//System.out.println(elem.getName() + " = " + 
elem.getValue());
 }
  }

 }

When I use my browser to the html file, put some data in the "dataParam" 
text area and
hit Submit,  I got the following result in Tomcat stdout.log

NAME = 'class'. VALUE = 'File'
NAME = 'cmd'. VALUE = 'Add'
'sword>bejo1663eb7d56063ec67f23be
ELEM is a file
FILENAME = ch-p506-2_enable_callhome.cfg
FILE PATH = C:\Temp\strts4674.tmp
NAME = 'SUBMIT'. VALUE = 'Submit Query'

My question is:
--
* Is there an explanation on why the "dataParam" parameter is not printed out,
or printed out but has the wrong value ?
* I also have written a Java multipart writer to test it, but it looks like 
that the file is always
   larger by 2 bytes. Isn't the format for multipart request like this:
   --Boundary\r\n
   content-disposition: form-data; name="blah"; filename="file.txt"\r\n
   Content-type: application/octet-stream\r\n
\r\n
Body goes here..
   --Boundary--\r\n
   Am I correct about the CRLF (\r\n) ? I have read RFC 1867 and RFC 2046 
and it looks correct.
   Any ideas ?

Thanks in advance.
Marli.


--
To unsubscribe, e-mail:   
For additional commands, e-mail: