signoff JSP-INTEREST
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Jay Foster
Sent: Wednesday, March 28, 2001 8:25 PM
To: [EMAIL PROTECTED]
Subject: Re: <input type=file>
Martin:
Here is a snippet of code based on the examples that come with the
com.oreilly.servlet (COS) package written by Jason Hunter. The COS
package is a set of servlet utility classes. The COS package and
examples are available from http://www.servlets.com
--------------
public void doPost( HttpServletRequest request, HttpServletResponse
response ) throws ServletException, IOException
{
PrintWriter out = response.getWriter();
response.setContentType("text/plain");
try
{
MultipartRequest multi = new MultipartRequest( request,
<upload
directory>, 10*1024*1024 ); // 10MB
Enumeration files = multi.getFileNames();
while( files.hasMoreElements() )
{
String name = (String)files.nextElement();
String filename = multi.getFilesystemName(name);
String type = multi.getContentType(name);
File f = multi.getFile(name);
out.println("name: " + name);
out.println("filename: " + filename);
out.println("type: " + type);
if( f != null )
{
out.println("f.toString(): " +
f.toString());
out.println("f.getName(): " + f.getName());
out.println("f.exists(): " + f.exists());
out.println("f.length(): " + f.length());
}
}
}
catch( IOException e )
{
// handle exception
}
}
Hope this helps.
Regards,
Jay
--------------
Martin Pribyl wrote:
>
> Hi,
> how could I get the content and the name of the file, when I use the input
> form element with the type=file?
> Either using the request object, or using the java bean to handle the form
> with the directive <jsp:useBean> (rather)
> Thanks a lot,
> Martin
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
> 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".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
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".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
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