If all you want to do is validate form fields, JavaScript is probably the
best way to do it...
/Tommy
-----Original Message-----
From: Sundeep Goswami [mailto:[EMAIL PROTECTED]]
Sent: den 17 augusti 2000 01:33
To: [EMAIL PROTECTED]
Subject: Re: Getting form parameters
Could you tell me how i can use the two forms??
basically i am having this problem becos i need to validate the text fields
before i go ahead and upload the file to the database and so the multipart
request which goes through the inputstream doesnt work well.
Maybe i can use the two forms too?
Thanks.
>From: Kevin Duffey <[EMAIL PROTECTED]>
>Reply-To: A mailing list about Java Server Pages specification and
> reference <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Re: Getting form parameters
>Date: Wed, 16 Aug 2000 12:30:51 -0700
>
>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.
===========================================================================
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