home | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Java EE 6 example source code file (getParts.jsp)

This example Java EE 6 source code file (getParts.jsp) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Java EE 6 tags/keywords

content, content, example, example, names, names, part, part, received, server, size, string, type, upload

The Java EE 6 getParts.jsp source code

<%@ page import="javax.servlet.http.Part" %>

  <title>File Upload Example

  <h1>Files Received at the Server

  for (Part p: request.getParts()) {

    /* out.write("Part: " + p.toString() + "<br/>\n"); */
    out.write("Part name: " + p.getName() + "<br/>\n");
    out.write("Size: " + p.getSize() + "<br/>\n");
    out.write("Content Type: " + p.getContentType() + "<br/>\n");
    out.write("Header Names:");
    for (String name: p.getHeaderNames()) {
        out.write(" " + name);
\n"); /* * If the part is a text file, the following code can be added to read * the uploaded file, and dumps it on the response. java.io.InputStreamReader in = new java.io.InputStreamReader(p.getInputStream()); int c = in.read(); while (c != -1) { if (c == '\n') out.write("<br/>"); out.write(c); c = in.read(); } */ } %> </body> </html>

Other Java EE 6 examples (source code examples)

Here is a short list of links related to this Java EE 6 getParts.jsp source code file:

my book on functional programming


new blog posts


Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.