title: Success string not found jupload on tomcat 7
body: <p>I was previously using jupload with tomcat 5.5 and it worked great! Now I was tasked with upgrading tomcat to version 7(7.0.70 to be exact) and found out that jupload no longer works. I havent changed the code one bit .Only thing changed is the tomcat distr,(I even used the same connector definition on server xml) 
  So here is my code 
  jsp page </p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=cp1251"
      pageEncoding="cp1251"%&gt;
  &lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%&gt;
  &lt;%@ page session="false"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=cp1251"&gt;
  &lt;title&gt;Загрузка файлов&lt;/title&gt;
  &lt;link rel=stylesheet type="text/css" href="/styles/style.css"&gt;
  &lt;style&gt;
  .td {
      valign: top
  }
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body style="background-color: white;"&gt;
      &lt;APPLET CODE="wjhk.jupload2.JUploadApplet" NAME="JUpload"
          ARCHIVE="${pageContext.request.contextPath}/applets/lib/jupload.jar"
          WIDTH="640" HEIGHT="300" MAYSCRIPT
          ALT="The java pugin must be installed."&gt;
          -
          &lt;c:choose&gt;
              &lt;c:when test="${param.par_type==1}"&gt;
                  &lt;param name="postURL"
                      value="${pageContext.request.contextPath}/protected/MultipleFileUpload?par_type=1" /&gt;
              &lt;/c:when&gt;
              &lt;c:when test="${param.par_type==2}"&gt;
                  &lt;param name="postURL"
                      value="${pageContext.request.contextPath}/protected/MultipleFileUpload?par_type=2" /&gt;
              &lt;/c:when&gt;
              &lt;c:when test="${param.par_type==3}"&gt;
                  &lt;param name="postURL"
                      value="${pageContext.request.contextPath}/protected/MultipleFileUpload?par_type=3" /&gt;
              &lt;/c:when&gt;
              &lt;c:otherwise&gt;
                  &lt;param name="postURL"
                      value="${pageContext.request.contextPath}/protected/MultipleFileUpload" /&gt;
              &lt;/c:otherwise&gt;
          &lt;/c:choose&gt;
          &lt;param name="afterUploadURL"
              value="${pageContext.request.contextPath}/protected/MultipleFileUpload" /&gt;
          &lt;param name="allowedFileExtensions" value="xml/osf/zsf/plax" /&gt;
          &lt;param name="afterUploadURL"
              value="javascript:alert('Загрузка файлов успешно завершена');window.opener.location.href = '../protected/sheet/plan/EducPlansStorage';window.close();" /&gt;
          &lt;param name="showLogWindow" value="true" /&gt;
          &lt;param name="debugLevel" value="0" /&gt;
          &lt;param name="stringUploadSuccess" value="^SUCCESS" /&gt;
          &lt;param name="lookAndFeel" value="system" /&gt;
      &lt;/APPLET&gt;
  &lt;/body&gt;
  &lt;/html&gt;       
  </code></pre>
  
  <p>server side  MultipleFileUpload Servlet </p>
  
  <pre><code>  package com.ieml.servlets.plan;
  
      import java.io.*;
      import java.sql.*;
      import java.util.*;
  
      import javax.servlet.*;
      import javax.servlet.http.*;
  
      import org.apache.commons.fileupload.*;
  
      import org.apache.commons.fileupload.disk.*;
      import org.apache.commons.fileupload.servlet.*;
  
      import com.ieml.Global;
      import com.ieml.util.*;
  
      /**
       * Servlet implementation class for Servlet: UploadInfoFileServlet
       *
       */
      public class MultipleFileUploadServlet extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
          private static final long serialVersionUID = 1L;
  
          protected void doHead(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              doPost(request, response);
          }   
  
          protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              doPost(request, response);
          }   
  
          protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
          {
              PrintWriter out = response.getWriter();
              String path = com.ieml.Global.getUploadDirectory();
              Integer type= ServletUtilities.getIntParameter(request, "par_type");
              if(path == null)
              {
                  ServletUtilities.forwardErrorPage(request, response, "Не указано место хранения файлов");           
                  return;         
              }
              if(type==null)
              {
                  ServletUtilities.forwardErrorPage(request, response, "Не указан тип плана");            
                  return;         
              }
              else
              {
                  switch(type)
                  {
                  case 1:path+="/plans/incoming/"; break;
                  case 2:path+="/plansMag/incoming/";break;
                  case 3:path+="/plansSPO/incoming/";break;
                  }
              }
  
              boolean isMultipart = ServletFileUpload.isMultipartContent(new ServletRequestContext(request));
  
              if (isMultipart) 
              {
                  try
                  {
                      FileItemFactory factory = new DiskFileItemFactory();
                      ServletFileUpload upload = new ServletFileUpload(factory);
                      upload.setHeaderEncoding("UTF-8");
                      List&lt;?&gt; items = upload.parseRequest(request);
                      Iterator&lt;?&gt; iter = items.iterator();
                      while(iter.hasNext())
                      {
                          FileItem item = (FileItem)iter.next();                
                          if (!item.isFormField()) 
                          {
                              String fileName = item.getName();
                              if(!fileName.endsWith(".xml") &amp;&amp;!fileName.endsWith(".XML") &amp;&amp;
                                      !fileName.endsWith(".osf") &amp;&amp; !fileName.endsWith(".OSF") &amp;&amp;
                                      !fileName.endsWith(".zsf") &amp;&amp; !fileName.endsWith(".ZSF")&amp;&amp;
                                      !fileName.endsWith(".plax") &amp;&amp; !fileName.endsWith(".PLAX")
                                      )
                              {
                                  ServletUtilities.forwardErrorPage(request, response, "Поддерживаемые формат файлов: .xml");
                                  return;         
                              }
                              Connection conn = Global.getConnection();                   
                              try {
  
                                  File f = new File(path,   fileName);
                                  if(f.exists()) f.delete();                    
  
                                  File uploadedFile = new File(path, fileName);
                                  try
                                  {
                                      item.write(uploadedFile);
                                  }
                                  catch(Exception e)
                                  {
                                      e.printStackTrace();
                                      log(e.getMessage());
                                      ServletUtilities.forwardErrorPage(request, response, "Не могу записать файл.");
                                  }
                              }                   
                              finally
                              {
                                  conn.close();
                              }
                              break;
                          }
                      }
                      out.println("SUCCESS");
                  }
                  catch(SQLException e){
                      e.printStackTrace();
                  }
                  catch(FileUploadException fue){
                      fue.printStackTrace();
                      log(fue.getMessage());
                      ServletUtilities.forwardErrorPage(request, response, "Не могу принять файл.");              
                  }
              }   
          }
      }  
  </code></pre>
  
  <p>Here is my jupload log for  the errror 
  <a href="http://pastebin.com/xUaSjKdV" rel="nofollow">http://pastebin.com/xUaSjKdV</a></p>
  
  <p>It looks to me that after jupload start preparing the upload for some reason it redirects to web application root(which in turn gets redirected  to protected area of the website which requires a login )In both case user is already loggged in when he goes to jsp page. .So for some strange reason just  searches for success string inside the login page which doesnt contain it of course so the error pops up. I am wondering why its redirecting to the web app root in the first place . I thought it might be something to do with timeout issue, changed the default parameter of  asyncTimeout to "6000 (this parameter didnt exist in the 5.5 version according to the docs)  but still no luck . Here is my basic port 8080 Connecto on the localhost   on tomcat </p>
  
  <pre><code> &lt;Connector  acceptCount="100"  protocol="org.apache.coyote.http11.Http11Protocol" connectionTimeout="20000" disableUploadTimeout="true" enableLookups="false" maxHttpHeaderSize="8192" maxSpareThreads="75" maxThreads="150" minSpareThreads="25" port="8080" redirectPort="8443"/&gt;
  </code></pre>
  
  <p>Any ideas?</p>