Hi,
As far as I know, the only way to upload binary data (files, images, etc) is
through the enctype set to form-multipart (or something like that..forget it
off hand). Because the encoding is done differently than "normal" forms
(those without files), to grab parameters other than the file, you have to
go through the same process for all parameters..you can't call
request.getParameter() on it. There are FileUploadServlet classes available.
Orion has one built in I believe, and I think other app servers do too.
> -----Original Message-----
> From: Calixto Melean [mailto:[EMAIL PROTECTED]]
> Sent: Friday, August 25, 2000 1:29 PM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: Getting form parameters
>
>
> Kevin,
>
> I am exploring ways to upload files. You seem to imply there are ways
> other than "file with a form" to accomplish this. Is this right, where
> could I find information on this? Do I have to use this multipart
> request class?
>
> thanks
>
> Kevin Duffey wrote:
> >
> > Hi,
> >
> > The problem lies in how its encoded. Because your uploading a
> file WITH a
> > form, you'll have to manually get the fields.
> request.getParameter() doesn't
> > work in getting form values if you use the enctype your using.
> So, if you
> > must upload a file WITH a form, you'll have to use a
> FileUploadServlet that
> > reads in the parameters of the form AND the binary data of the
> file. Luckily
> > on my site we use a single form for the file, and a different
> form for the
> > rest of the fields.
> >
> > > -----Original Message-----
> > > From: A mailing list about Java Server Pages specification
> and reference
> > > [mailto:[EMAIL PROTECTED]]On Behalf Of Sundeep Goswami
> > > Sent: Wednesday, August 16, 2000 10:06 AM
> > > To: [EMAIL PROTECTED]
> > > Subject: Getting form parameters
> > >
> > >
> > > Hello!,
> > > I have a form with the enctype=multipart/form-data
> > > I need to upload a file but before i do that i need to get
> the paramters
> > > from the text fields and validate the values if successful i
> need to call
> > > the MultipartRequest class to do the actual upload.
> > > The problem i am facing is that in the Upload.java servlet,
> > > doPost method i
> > > am unable to get the values from the request object.
> > > I have provided the code snippet
> > >
> > > Upload.java
> > >
> > > public class Upload extends HttpServlet {
> > >
> > > public void doPost(HttpServletRequest req, HttpServletResponse res)
> > > throws ServletException, IOException {
> > > res.setContentType("text/html");
> > > PrintWriter out = res.getWriter();
> > >
> > > -- this returns a null
> > > System.out.println ("The name is " + req.getParameter ("Name"));
> > >
> > > MultipartRequest multi = new MultipartRequest(req);
> > >
> > > -- now this gives a valid value
> > > System.out.println ("the name is " + multi.getParameter("Name"));
> > > }
> > > }
> > >
> > > The getParameter method is provided in the MultipartRequest class.
> > > The problem is due to the "multipart/form-data" attribute. Can
> > > someone help
> > > me out with this and tell me how i can get the information from
> > > the request
> > > object before i call the multipartrequest class.
> > >
> > > Thanks.
> > >
> ________________________________________________________________________
> > > Get Your Private, Free E-mail from MSN Hotmail at
http://www.hotmail.com
> >
> > ==================================================================
> > =========
> > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> > JSP-INTEREST".
> > Some relevant FAQs on JSP/Servlets can be found at:
> >
> > http://java.sun.com/products/jsp/faq.html
> > http://www.esperanto.org.nz/jsp/jspfaq.html
> > http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> > http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
> >
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets