I am trying to use it now from within the JSP and calling the class.
However, it saves all the elements of the form as a file! Why is this?

Here is my code:

------------------------
<%@
 page language="java"
 import="java.io.*, java.util.*, java.sql.*"
%>

<font face=verdana size=1>
<%

 //----------------------------------
 // Initialize the variables
 //----------------------------------
 String uploadDir  = "D:" + java.io.File.separator + "temp";
 String fileDestination  = uploadDir + java.io.File.separator;
 String currSessionID = session.getId() + "";

 File CMSUploadDir = new File(fileDestination);
   CMSUploadDir.mkdirs();

 //----------------------------------
 // Call the functions
 //----------------------------------
   com.oreilly.servlets.MultipartHandler m = new
   com.oreilly.servlets.MultipartHandler(request
               ,fileDestination
               ,1024*1024
               ,currSessionID);

 //----------------------------------
 // List all the parameters
 //----------------------------------
 Enumeration params = m.getParameterNames();
  while (params.hasMoreElements())
 {
  String name = (String)params.nextElement();
  String value = m.getParameter(name);
  out.println("<b>" + name + "</b> = " + value + "<br>");
  }
  out.println("<P>");

 //----------------------------------
 // List all the files uploaded
 //----------------------------------
  Enumeration files = m.getFileNames();
  while (files.hasMoreElements())
 {
  String f_name = (String) files.nextElement();
  File f_value = m.getFile(f_name);
  out.println("<b>" + f_name + "</b> = " + f_value + "<br>");
  }
  out.println("<P>");


%>
</font>


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


My form has :

text INPUT : col1
text INPUT : col2
file INPUT : col3
text INPUT : col4


The output from the above program is:



---
col4 = D:\temp\ilK1XlTJbjD2qe15I0_null
col3 = D:\temp\ilK1XlTJbjD2qe15I0_balance.gif
col2 = D:\temp\ilK1XlTJbjD2qe15I0_null
col1 = D:\temp\ilK1XlTJbjD2qe15I0_null
Submit = D:\temp\ilK1XlTJbjD2qe15I0_null
---


If you notice, then the text fields are also getting saved as files!!! (I am
pre-appending the session ID to the file names).

Any idea would be appreciated!

Thanks,
Mike








----- Original Message -----
From: "CPC Livelink Admin" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, November 27, 2000 6:13 PM
Subject: RE: Multipart stuff - inside JSP?


>
> I use it all the time in my JSPs.  I don't understand why you are trying
to
> embed the source in the JSP instead of just using it though - Here is how
I
> use it :
>
>
>
> <%@
> page language="java"
> import="java.io.*, java.util.*"
> errorPage="load-action-docs-error.jsp"
> %>
> 8< snip >8
> <%
>   String FileDestination = strMSUploadDir + java.io.File.separator +
> session.getId();
>   File fUploadDir = new File(FileDestination);
>   fUploadDir.mkdirs();
>
>   com.oreilly.servlet.MultipartRequest multi = new
> com.oreilly.servlet.MultipartRequest(request, FileDestination,
> iMSMaxFileSize);
>
>   Enumeration files = multi.getFileNames();
>   while (files.hasMoreElements()) {
>
>     ... etc (like HTML) below ...
>
> -----Original Message-----
> From: Mike Kobe [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, November 28, 2000 01:36 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Multipart stuff - inside JSP?
>
>
> Hi,
>
> I was looking at the multipart request handler from oreilly,
> (www.servlets.com), is it possible to use the same class INSIDE jsp? I
mean
> in the declaration tags
>
>     <%!
>
>         class MultipartRequest...
>
>     %>
>
>
> and then call it from there? This is giving me a hell lot of problems.
> First, all the IMPORT tags in the class were giving me a problem, so I
> removed all those, but now it gives me a problem with the "Hashtable" from
> java.util.*, so I removed all of that, and the reference to all
"Vectors"..
>
> Now it doesnt work! ALways gives me the "premature ending" IOException..
>
> Please help! Is there something that I cannot do inside the JSP
declaration
> tags? How to go around this?
>
> Thanks!!!
> Mike
>
>
>

Reply via email to