Using Tomcat 6.0.18 (to be 6.0.26) and Google App Engine, for parallel
development (different db tech)
Short form: I need to accept a file upload in a servlet, do some
computations on the upload, and then transition to a JSP with some
data resulting from the computations. I'm having some trouble with the
transition at the end. I need either to make the current code work or
find an
alternate way to achieve the goal.
Long form. Here's the html for file upload (vanilla):
<form name="csvUploadForm" action="csvfileupload" method="post"
enctype="multipart/form-data">
File:<input type="file" name="csvfile2upload"><br></br>
<input type="submit" name="Submit" value="Upload CSV File"
onclick="uploadCSVFile();return false;">
</form>
Here's the servlet mapping for the receiving/processing servlet:
<servlet-mapping>
<servlet-name>CSVFileUpload</servlet-name>
<url-pattern>/csvfileupload/*</url-pattern>
</servlet-mapping>
The CSVFileUpload servlet doPost method uses
org.apache.commons.fileupload.servlet.ServletFileUpload;
to accept and process the upload, and puts the resulting data into the
db. If I don't care about duplicates or partial matches,
this works fine; at the end of the servlet processing, I execute
response.sendRedirect("/myStartPage.jsp");
-- where response is the doPost's HttpServletResponse.
Now I need to deal with partial matches between incoming data from the
upload, and information already in the db. Specifically,
I need to interact with the user to determine how to resolve the
ambiguities. I /thought/ I could create a bean with the necessary
computed
info, use setAttribute to attach the bean to request (the doPost's
HttpServletRequest), and then forward to a JSP with code like this:
String nextJSP = "/nextPage.jsp";
RequestDispatcher dispatcher =
getServletContext().getRequestDispatcher(nextJSP);
dispatcher.forward(request, response);
Unfortunately, I'm running into the following errors showing in the log:
WARNING: Nested in javax.servlet.ServletException:
org.apache.commons.fileupload.FileUploadBase
$InvalidContentTypeException: the request doesn't contain a multipart/
form-data or multipart/mixed stream, content type header is null:
org.apache.commons.fileupload.FileUploadBase
$InvalidContentTypeException: the request doesn't contain a multipart/
form-data or multipart/mixed stream, content type header is null
at org.apache.commons.fileupload.FileUploadBase
$FileItemIteratorImpl.<init>(FileUploadBase.java:885)
at
org
.apache
.commons.fileupload.FileUploadBase.getItemIterator(FileUploadBase.java:
331)
at
org
.apache
.commons
.fileupload
.servlet.ServletFileUpload.getItemIterator(ServletFileUpload.java:148)
at
com
.formrunner
.servlets.CSVFileUploadServlet.doPost(CSVFileUploadServlet.java:53)
at
com
.formrunner
.servlets.CSVFileUploadServlet.doGet(CSVFileUploadServlet.java:29)
.....
The browser actually displays the nextPage.jsp page. However, if one
then clicks any navigation button, you get a version of the warning
above showing in the browser.
I'm assuming that the CSVFileUpload servlet processing of the upload
has stripped the request; hence the errors.
My goal is to get from the CSVFileUpload servlet to the nextPage.jsp
with the "partialMatch" data in hand. In the normal use case, this
will only be a couple of text lines. However, at the extreme it could
be hundreds of lines of mismatches. I really don't care how I
accomplish the transition to nextPage.jsp, so if there's a better way
than what I'm attempting here, please let me know.
{Anything written on the web would be great.} [I assume that I could
store the "partialMatch" data in the db under some appropriate key,
get to nextPage using response.sendRedirect, and then retrieve the
info, but that seems like more of a hack than ought to be necessary
here.]
Thanks in advance,
Ken
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org