%@ page trimDirectiveWhitespaces="true" %> <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <%@ page import="org.apache.commons.fileupload.*" %> <%@ page import="java.io.BufferedReader" %> <%@ page import="java.io.File" %> <%@ page import="java.io.InputStream" %> <%@ page import="java.io.BufferedOutputStream" %> <%@ page import="java.io.InputStreamReader" %> <%@ page import="java.util.List" %> <%@ page import="java.net.URL" %> <%@ page import="org.crosswire.utils.HTTPUtils" %> <% String requestURI = request.getRequestURI(); int pe = requestURI.lastIndexOf('/', requestURI.length()-2); requestURI = (pe > 0) ? requestURI.substring(0, pe) : ""; URL baseURL = new URL(request.getScheme(), request.getServerName(), request.getServerPort(), requestURI); URL appBaseURL = new URL(request.getScheme(), request.getServerName(), request.getServerPort(), "/community/"); String userID = null; try { DiskFileUpload fu = new DiskFileUpload(); // maximum size before a FileUploadException will be thrown fu.setSizeMax(99000000); // maximum size that will be stored in memory fu.setSizeThreshold(4096); // the location for saving data that is larger than getSizeThreshold() fu.setRepositoryPath(session.getServletContext().getRealPath("tmp/")); List fileItems = fu.parseRequest(request); // assume we know there are two files. The first file is a small // text file, the second is unknown and is written to a file on // the server for (int i = 0; i < fileItems.size(); i++) { FileItem fi = (FileItem)fileItems.get(i); if (fi.isFormField()) { if ("userID".equals(fi.getFieldName())) { userID = fi.getString(); } } else { response.setContentType("text/xml"); byte xml[] = fi.get(); String text = new String(xml); String params = "text="+java.net.URLEncoder.encode(text); String importURL = new URL(appBaseURL, "vmr/api/transcript/import/").toString(); StringBuffer result = HTTPUtils.postURL(importURL, params); out.print(result); return; } } } catch (Exception e) { e.printStackTrace(); } %>