• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to solve java.io.IOException: Corrupt form data: premature ending  RSS feed

 
Yong Ming Wai
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hei evryone!


Does anyone knows how to solve this bug?

java.io.IOException: Corrupt form data: premature ending

Im using Oreilly's cos.jar MultipartRequest
here is my form :
function save()
{
var agree = confirm("Are you sure you wish to submit this form ?");

if (agree)
{
document.form1.action="../servlet/ehr.toll.ats.AtsGlcMultipartServlet";
document.form1.encoding = "multipart/form-data";
document.form1.al.value= "submit";
document.form1.sy.value= "EXTERNALCOURSEDIRNEW";
document.form1.submit();
}

}
<form name="form1" method="POST" action="" id="form1">

<table cellspacing=1 cellpadding=4 width="100%">
<tbody>
<TR>..............</TR>
<TR>..............</TR>
<TR>..............</TR>
<TR ALIGN="left" VALIGN="top">
<td class=bg6 width="30%"><span class="textb">Brochure Attachment</span></td>
<TD class=bg7><span class=textdata>File Name
<INPUT TYPE="file" NAME="fileName" SIZE="50" class="textdata" value="<%= fileName %>" ACCEPT="" >
</span></TD>
</tr>
<TR>..............</TR>
<TR>..............</TR>

</tbody>
</table>
</form>

HERE IS AtsGlcMultipartServlet which is a servlet :

package ehr.toll.ats;

import ehr.utility.*;
import ehr.classes.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.sql.*;
import java.math.*;
import com.oreilly.servlet.*;
import com.oreilly.servlet.multipart.*;

public class AtsGlcMultipartServlet extends HttpServlet {

/**
* @see javax.servlet.http.HttpServlet#void (javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}

/**
* @see javax.servlet.http.HttpServlet#void (javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException
{
try
{
MultipartRequest multi = null;
AtsGlcControlServlet atsGlcCtrl = new AtsGlcControlServlet();

String nextExtPage2 = "/ehr/toll/ats/glc/ATS_GLC_COURSE_DIRECTORY.jsp";

String nextPage = "";

String sy = "";
String al = "";

try
{
System.out.println("SecurityProperty.getFilesDirectory()-"+SecurityProperty.getFilesDirectory());

multi = new MultipartRequest(request, SecurityProperty.getFilesDirectory() + "ats", SecurityProperty.getMaxPostSize(), new com.oreilly.servlet.multipart.DefaultFileRenamePolicy());


}
catch (IOException ioe)
{
//ignore
System.out.println("error-"+ioe);
}

if (multi != null)
{
sy = Util.nullCheckStr(multi.getParameter("sy"));
al = Util.nullCheckStr(multi.getParameter("al"));

String syParam = "?sy=" + sy;
String syParam2= "&al=" + al;


System.out.println("sy-"+sy);
System.out.println("al-"+al);

if (sy.equals("EXTERNALCOURSEDIRNEW"))
{
if (al.equals("submit"))
{
request = AtsGlcControlServlet.atsGlcExtCrsDirMulti(request,"submit",multi);
request = AtsGlcControlServlet.atsGlcExtCrsDir(request, "view");
syParam = "?sy=EXTERNALCOURSEDIR";

nextPage = nextExtPage2 + syParam;
}
}
else
{
logOut(request, response, "nopage");
}
}
else
{
logOut(request, response, "nopage");
}
response.setContentType("text/html");
response.setHeader("Cache-Control", "no-store");
response.setHeader("Pragma", "no-cache");
RequestDispatcher disp = getServletContext().getRequestDispatcher(nextPage);
disp.include(request, response);

}
catch(Throwable theException)
{
// uncomment the following line when unexpected exceptions
// are occuring to aid in debugging the problem.
if(SecurityProperty.getPrintStack())
{
theException.printStackTrace();
}
}
}
It able to upload the file into the directory.
However,the IOException causing other data insert to halt..
Searching on google doesn't provide much help..

Your response would be deeply appreciated.

alloy
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yong,

Javaranch tip:
If you are going to post more than a line or two of your code, wrap the code in UBB CODE tags. Doing so preserves your indenting which makes it easier to read. If it's easier to read, more people will read it and you will stand a better chance of getting help.
There is a button on the edit screen to help with this.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!