вот моя страница JSF / HTML
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<body>
<ui:composition template="./templates/template.xhtml">
<ui:define name="content">
<c:choose>
<c:when test="#{controls.designAuth}">
Welcome Report Designer!<br /><br />
<div id="fileUpload">
<form name="myForm" action="../UploadServlet" enctype="multipart/form-data" method="POST">
<b>Make sure your filename is meaningful (eg. WasteByMachineReport.jrxml)</b><br /><br />
Please specify a file:<input type="file" name="file" size="40"/><br /><br />
Number of parameters: <select name="numSelect" id='numSelect' onchange="draw_param_dropdowns();">
<option selected="selected" >0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
</select><br />
<br /><br />
<table border="0">
<tr style="background-color:#dddddd;color:black;"><td><span id ="tabletitles" style ="display: none;">Parameter Name</span></td><td><span width="200" id ="tabletitles2" style ="display: none;">Data Type</span></td></tr>
<tr style="background-color:#dddddd;color:black;"><td>
<input type="text" name="P1" id="P1" style="display:none;"></input></td><td><select id="Ptype1" name="Ptype1" style="display:none;">
<option>Date</option>
<option>String</option>
<option>Number</option></select>
</td></tr>
<tr style="background-color:#dddddd;color:black;"><td> <input type="text" name="P2" id="P2" style="display:none;"></input></td><td><select id="Ptype2" name="Ptype2" style="display:none;">
<option>Date</option>
<option>String</option>
<option>Number</option></select>
</td></tr> <tr style="background-color:#dddddd;color:black;"><td><input type="text" name="P3" id="P3" style="display:none;"></input></td><td><select id="Ptype3" name="Ptype3" style="display:none;">
<option>Date</option>
<option>String</option>
<option>Number</option></select>
</td></tr><tr style="background-color:#dddddd;color:black;"><td> <input type="text" name="P4" id="P4" style="display:none;"></input></td><td><select id="Ptype4" name="Ptype4" style="display:none;">
<option>Date</option>
<option>String</option>
<option>Number</option></select>
</td></tr><tr style="background-color:#dddddd;color:black;"><td> <input type="text" name="P5" id="P5" style="display:none;"></input></td><td><select id="Ptype5" name="Ptype5" style="display:none;">
<option>Date</option>
<option>String</option>
<option>Number</option></select>
</td></tr><tr style="background-color:#dddddd;color:black;"><td> <input type="text" name="P6" id="P6" style="display:none;"></input></td><td><select id="Ptype6" name="Ptype6" style="display:none;">
<option>Date</option>
<option>String</option>
<option>Number</option></select>
</td></tr> <tr style="background-color:#dddddd;color:black;"><td><input type="text" name="P7" id="P7" style="display:none;"></input> </td><td><select id="Ptype7" name="Ptype7" style="display:none;">
<option>Date</option>
<option>String</option>
<option>Number</option></select>
</td></tr><tr style="background-color:#dddddd;color:black;"><td> <input type="text" name="P8" id="P8" style="display:none;"></input></td><td><select id="Ptype8" name="Ptype8" style="display:none;">
<option>Date</option>
<option>String</option>
<option>Number</option></select>
</td></tr><tr style="background-color:#dddddd;color:black;"><td> <input type="text" name="P9" id="P9" style="display:none;"></input></td><td><select id="Ptype9" name="Ptype9" style="display:none;">
<option>Date</option>
<option>String</option>
<option>Number</option></select>
</td></tr><tr style="background-color:#dddddd;color:black;"><td><input type="text" name="P10" id="P10" style="display:none;"></input></td><td> <select id="Ptype10" name="Ptype10" style="display:none;">
<option>Date</option>
<option>String</option>
<option>Number</option></select>
</td></tr><tr style="background-color:#dddddd;color:black;"><td><input type="text" name="P11" id="P11" style="display:none;"></input></td><td> <select id="Ptype11" name="Ptype11" style="display:none;">
<option>Date</option>
<option>String</option>
<option>Number</option></select>
</td></tr><tr style="background-color:#dddddd;color:black;"><td><input type="text" name="P12" id="P12" style="display:none;"></input> </td><td><select id="Ptype12" name="Ptype12" style="display:none;">
<option>Date</option>
<option>String</option>
<option>Number</option></select>
</td></tr><tr style="background-color:#dddddd;color:black;"><td><input type="text" name="P13" id="P13" style="display:none;"></input> </td><td><select id="Ptype13" name="Ptype13" style="display:none;">
<option>Date</option>
<option>String</option>
<option>Number</option></select>
</td></tr><tr style="background-color:#dddddd;color:black;"><td> <input type="text" name="P14" id="P14" style="display:none;"></input></td><td><select id="Ptype14" name="Ptype14" style="display:none;">
<option>Date</option>
<option>String</option>
<option>Number</option></select>
</td></tr><tr style="background-color:#dddddd;color:black;"><td> <input type="text" name="P15" id="P15" style="display:none;"></input></td><td><select id="Ptype15" name="Ptype15" style="display:none;">
<option>Date</option>
<option>String</option>
<option>Number</option></select>
</td></tr></table>
<script type="text/javascript" language="Javascript">
function draw_param_dropdowns(){
for (var x = 1; x <= 15; x++) {
document.getElementById('Ptype' + x).style.display='none';
document.getElementById('P' + x).style.display='none';
document.getElementById("tabletitles").style.display = 'none';
document.getElementById("tabletitles2").style.display = 'none';
}
if (document.getElementById("numSelect").selectedIndex >=1)
{document.getElementById("tabletitles").style.display = 'block';
document.getElementById("tabletitles2").style.display = 'block';}
for (var y = 1; y <= document.getElementById("numSelect").selectedIndex; y++) {
document.getElementById('Ptype' + y).style.display = 'block';
document.getElementById('P' + y).style.display = 'block';
}
}
</script>
<input type="submit" value="Upload"/>
</form>
</div>
</c:when>
<c:otherwise>
Not Authorized
</c:otherwise>
</c:choose>
</ui:define>
</ui:composition>
</body>
а вот сервлет java, который, как я уже говорил, работал для загрузки файлов неделю назад или около того
/*\_________________________________________________
* To change this template, choose Tools | Templates
* and open the template in the editor.
\*///-----------------------------------------------
package DBFunctions;
// Import required java libraries
import java.io.*;
import java.util.*;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.io.output.*;
public class UploadServlet extends HttpServlet {
private boolean isMultipart;
private String filePath;
private int maxFileSize = 200 * 1024;
private int maxMemSize = 4 * 1024;
private File file ;
private String name;
private String reportTitle;
@Override
public void init(){
// Get the file location where it would be stored.
filePath = "c:\\Projects\\WebApplication8\\web\\uploads\\";
}
@Override
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, java.io.IOException {
// Check that we have a file upload request
isMultipart = ServletFileUpload.isMultipartContent(request);
request.getParameter(null);
response.setContentType("text/html");
java.io.PrintWriter out = response.getWriter( );
if( !isMultipart ){
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet upload</title>");
out.println("</head>");
out.println("<body>");
out.println("<p>No file uploaded</p>");
out.println("</body>");
out.println("</html>");
return;
}
DiskFileItemFactory factory = new DiskFileItemFactory();
// maximum size that will be stored in memory
factory.setSizeThreshold(maxMemSize);
// Location to save data that is larger than maxMemSize.
factory.setRepository(new File("c:\\temp"));
// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload(factory);
// maximum file size to be uploaded.
upload.setSizeMax( maxFileSize );
try{
// Parse the request to get file items.
List fileItems = upload.parseRequest(request);
// Process the uploaded file items
Iterator i = fileItems.iterator();
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet Upload</title>");
out.println("</head>");
out.println("<body><div style='position:absolute;width:500px;height:700px;left:35%;background-color:#d2d2d2;'><center><br /><br /><br /><br /><br />");
//out.println(filePath);
while ( i.hasNext () )
{
FileItem fi = (FileItem)i.next();
if ( !fi.isFormField () )
{
// Get the uploaded file parameters
String fieldName = fi.getFieldName();
String fileName = fi.getName();
String contentType = fi.getContentType();
boolean isInMemory = fi.isInMemory();
long sizeInBytes = fi.getSize();
// Write the file
name = fileName;
if( fileName.lastIndexOf("\\") >= 0 ){
file = new File( filePath +
fileName.substring( fileName.lastIndexOf("\\")));
}else{
file = new File( filePath +
fileName.substring(fileName.lastIndexOf("\\")+1));
}
fi.write( file );
out.println("<br /><br />Uploaded Filename: " + fileName + "<br>");
}
}
out.println("<br /><br /><a href='/WebApplication8/faces/it.xhtml'>Add New File to / Edit Menu Tree</a><br /><br /><br />");
out.println("<a href='/WebApplication8/faces/designer.xhtml'>Back</a></center></div>");
//-------------------------------------------------------------------------
// String params =request.getParameter("numParams");
//
//
// int numParams = Integer.parseInt(params);
//
// out.println(numParams);
DBConnect db = new DBConnect();
boolean result = db.DBConnectAndUpdate("INSERT INTO PLANT.APPLIC VALUES (9999, '" + name + "','R','" + "',0,'eng')");
//-------------------------------------------------------------------------
out.println("</body>");
out.println("</html>");
}catch(Exception ex) {
System.out.println(ex.getMessage());
}
}
@Override
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, java.io.IOException {
throw new ServletException("GET method used with " +
getClass( ).getName( )+": POST method required.");
}
}
а вот и ошибка
Я посмотрел на ошибку и просмотрел весь сервлет на предмет отсутствия двоеточий или чего-то глупого, но я не вносил никаких изменений буквально с тех пор, как в последний раз он работал
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.NullPointerException
java.util.Hashtable.get(Hashtable.java:334)
org.apache.tomcat.util.http.Parameters.getParameterValues(Parameters.java:195)
org.apache.tomcat.util.http.Parameters.getParameter(Parameters.java:240)
org.apache.catalina.connector.Request.getParameter(Request.java:1066)
org.apache.catalina.connector.RequestFacade.getParameter(RequestFacade.java:355)
org.netbeans.modules.web.monitor.server.MonitorRequestWrapper.getParameter(MonitorRequestWrapper.java:199)
DBFunctions.UploadServlet.doPost(UploadServlet.java:54)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.26 logs.