-----BEGIN PGP SIGNED MESSAGE-----
Hi,
it seems to happen a foolish bug whenever JSP of Tomcat deals with
multipart/form-data. Since I have developed all my project with JSP, now it
becomes very difficult to change all source files into servlets. It seems
to be a bug when JSP performs getInputStreams method with request object ,
as you can see below. Below, you can see my source JSP file and the Tomcat
system message.
Can somebody help me what is happening?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"><!-- SerStar Formulario 2
-->
<%@ page session="true"
import="ErrorBean,javax.servlet.*,javax.servlet.http.*,java.io.*,
java.util.*;" errorPage="Errorpage.jsp" %>
<jsp:useBean id="errform" class="ErrorBean" scope="session" />
<HTML>
<HEAD>
<TITLE>SerStar - Cadastro </TITLE>
</HEAD>
<BODY bgcolor="#FFFFFF">
<%
errform.setCoderror("ErrorS020");
String cAddr = request.getRemoteAddr();
if ( cAddr.equals(session.getValue("serstar")))
{ %>
<FORM method="POST" name="formtwo"
action="/examples/servlet/StarServlet">
<%
PrintWriter out = response.getWriter();
if (request.getMethod().equals("POST") &&
request.getContentType().startsWith("multipart/form-data"))
{
int index =request.getContentType().indexOf("boundary=");
if ( index < 0)
{
System.out.println(" Stream inconsistente ");
}
}
String boundary= request.getContentType().substring(index+9);
byte[] tmpbuffer = new byte[8192];
int length=0;
String inputLine = null;
boolean moreData=true, naoachei=true;
ServletInputStream instream = request.getInputStream();
for (int i=1;i<21;i++)
{
while ( inputLine.indexOf(boundary) > 0 && moreData = true )
{
length = instream.readLine( tmpbuffer,0,tmpbuffer.length);
inputLine = new String( tmpbuffer, 0,0, length );
if ( length < 0 )
{
moreData = false;
}
}
if ( moreData )
{
length = instream.readLine(tmpbuffer,0,tmpbuffer.length);
inputLine = new String(tmpbuffer, 0,0,length);
if (( i == 1 ) &&
( inputLine.indexOf("nome") >= 0 ))
{
length =
instream.readLine(tmpbuffer,0,tmpbuffer.length);
inputLine = new String(tmpbuffer,0,0,length);%>
<INPUT type="HIDDEN" name="<%= nome %>"
value="<% = inputLine %>">
<%}
else
if (( i == 2 ) &&
( inputLine.indexOf("nomeart") >= 0 ))
{
length =
instream.readLine(tmpbuffer,0,tmpbuffer.length);
inputLine = new String(tmpbuffer,0,0,length);%>
<INPUT type="HIDDEN" name="<%= nomeart %>"
value="<% = inputLine %>">
<% }
else
if (( i == 3 ) &&
( inputLine.indexOf("sexo") >= 0 ))
{
length =
instream.readLine(tmpbuffer,0,tmpbuffer.length);
inputLine = new String(tmpbuffer,0,0,length);%>
<INPUT type="HIDDEN" name="<%= sexo %>"
value="<% = inputLine %>">
<% }
else
if (( i == 4 ) &&
( inputLine.indexOf("dia") >= 0 ))
{
length =
instream.readLine(tmpbuffer,0,tmpbuffer.length);
inputLine = new String(tmpbuffer,0,0,length);%>
<INPUT type="HIDDEN" name="<%= dia %>"
value="<% = inputLine %>">
<% }
else
if (( i == 5 ) &&
( inputLine.indexOf("mes") >= 0 ))
{
length =
instream.readLine(tmpbuffer,0,tmpbuffer.length);
inputLine = new String(tmpbuffer,0,0,length);%>
<INPUT type="HIDDEN" name="<%= mes %>"
value="<% = inputLine %>">
<% }
else
if (( i == 6 ) &&
( inputLine.indexOf("ano") >= 0 ))
{
length =
instream.readLine(tmpbuffer,0,tmpbuffer.length);
inputLine = new String(tmpbuffer,0,0,length);%>
<INPUT type="HIDDEN" name="<%= ano %>"
value="<% = inputLine %>">
<% }
else
if (( i == 7 ) &&
( inputLine.indexOf("profissao") >= 0 ))
{
length =
instream.readLine(tmpbuffer,0,tmpbuffer.length);
inputLine = new String(tmpbuffer,0,0,length);%>
<INPUT type="HIDDEN" name="<%= profissao %>"
value="<% = inputLine %>">
<% }
else
if (( i == 8 ) &&
( inputLine.indexOf("registro") >= 0 ))
{
length =
instream.readLine(tmpbuffer,0,tmpbuffer.length);
inputLine = new String(tmpbuffer,0,0,length);%>
<INPUT type="HIDDEN" name="<%= registro %>"
value="<% = inputLine %>">
<% }
else
if (( i == 9 ) &&
( inputLine.indexOf("end") >= 0 ))
{
length =
instream.readLine(tmpbuffer,0,tmpbuffer.length);
inputLine = new String(tmpbuffer,0,0,length);%>
<INPUT type="HIDDEN" name="<%= end %>"
value="<% = inputLine %>">
<% }
else
if (( i == 10 ) &&
( inputLine.indexOf("compl") >= 0 ))
{
length =
instream.readLine(tmpbuffer,0,tmpbuffer.length);
inputLine = new String(tmpbuffer,0,0,length);%>
<INPUT type="HIDDEN" name="<%= compl %>"
value="<% = inputLine %>">
<% }
else
if (( i == 11 ) &&
( inputLine.indexOf("bairro") >= 0 ))
{
length =
instream.readLine(tmpbuffer,0,tmpbuffer.length);
inputLine = new String(tmpbuffer,0,0,length);%>
<INPUT type="HIDDEN" name="<%= bairro %>"
value="<% = inputLine %>">
<% }
else
if (( i == 12 ) &&
( inputLine.indexOf("cidade") >= 0 ))
{
length =
instream.readLine(tmpbuffer,0,tmpbuffer.length);
inputLine = new String(tmpbuffer,0,0,length);%>
<INPUT type="HIDDEN" name="<%= cidade %>"
value="<% = inputLine %>">
<% }
else
if (( i == 13 ) &&
( inputLine.indexOf("estado") >= 0 ))
{
length =
instream.readLine(tmpbuffer,0,tmpbuffer.length);
inputLine = new String(tmpbuffer,0,0,length);%>
<INPUT type="HIDDEN" name="<%= estado %>"
value="<% = inputLine %>">
<% }
else
if (( i == 14 ) &&
( inputLine.indexOf("email") >= 0 ))
{
length =
instream.readLine(tmpbuffer,0,tmpbuffer.length);
inputLine = new String(tmpbuffer,0,0,length);%>
<INPUT type="HIDDEN" name="<%= email %>"
value="<% = inputLine %>">
<% }
else
if (( i == 15 ) &&
( inputLine.indexOf("calcado") >= 0 ))
{
length =
instream.readLine(tmpbuffer,0,tmpbuffer.length);
inputLine = new String(tmpbuffer,0,0,length);%>
<INPUT type="HIDDEN" name="<%= calcado %>"
value="<% = inputLine %>">
<% }
else
if (( i == 16 ) &&
( inputLine.indexOf("alturamts") >= 0 ))
{
length =
instream.readLine(tmpbuffer,0,tmpbuffer.length);
inputLine = new String(tmpbuffer,0,0,length);%>
<INPUT type="HIDDEN" name="<%= alturamts %>"
value="<% = inputLine %>">
<% }
else
if (( i == 17 ) &&
( inputLine.indexOf("alturacms") >= 0 ))
{
length =
instream.readLine(tmpbuffer,0,tmpbuffer.length);
inputLine = new String(tmpbuffer,0,0,length);%>
<INPUT type="HIDDEN" name="<%= alturacms %>"
value="<% = inputLine %>">
<% }
else
if (( i == 18 ) &&
( inputLine.indexOf("peso") >= 0 ))
{
length =
instream.readLine(tmpbuffer,0,tmpbuffer.length);
inputLine = new String(tmpbuffer,0,0,length);%>
<INPUT type="HIDDEN" name="<%= peso %>"
value="<% = inputLine %>">
<% }
else
if (( i == 19 ) &&
( inputLine.indexOf("olhos") >= 0 ))
{
length =
instream.readLine(tmpbuffer,0,tmpbuffer.length);
inputLine = new String(tmpbuffer,0,0,length);%>
<INPUT type="HIDDEN" name="<%= olhos %>"
value="<% = inputLine %>">
<% }
else
if (( i == 20 ) &&
( inputLine.indexOf("cabelos") >= 0 ))
{
length =
instream.readLine(tmpbuffer,0,tmpbuffer.length);
inputLine = new String(tmpbuffer,0,0,length);%>
<INPUT type="HIDDEN" name="<%= cabelos %>"
value="<% = inputLine %>"><%
}
}
}
byte fileBytes[] = new byte[100000];
int offset=0;
length = instream.readLine( tmpbuffer,0,tmpbuffer.length);
inputLine = new String(tmpbuffer,0,0,length);
while ( length > 0 )
{
if ( inputLine.indexOf(boundary) >=0 )
{
length = instream.readLine(tmpbuffer,
0,tmpbuffer.length);
inputLine = new
String(tmpbuffer,0,0,length); }
else
{
System.arraycopy ( tmpbuffer,
0,
fileBytes,
offset,
length);
offset+=length;
}
length = instream.readLine(tmpbuffer,0,tmpbuffer.length);
inputLine = new String(tmpbuffer,0,length);
}
String figura = new String(fileBytes,0,offset);%>
<INPUT type="HIDDEN" name="<%= foto %>"value="<% = figura %>">
<P><BR></P>
Error: 500
Location: /examples/jsp/serstar/Form2.jsp
Internal Servlet Error:
org.apache.jasper.JasperException: Unable to compile class for
JSPD:\jakarta\tomcat\work\localhost_8080%2Fexamples\_0002fjsp_0002fserstar_0
002fForm_00032_0002ejspForm2_jsp_22.java:144: Missing term.
out.write("\" \t\t\t\tvalue=\"");
^
D:\jakarta\tomcat\work\localhost_8080%2Fexamples\_0002fjsp_0002fserstar_0002
fForm_00032_0002ejspForm2_jsp_22.java:168: Missing term.
out.write("\" \t\t\t\tvalue=\"");
^
D:\jakarta\tomcat\work\localhost_8080%2Fexamples\_0002fjsp_0002fserstar_0002
fForm_00032_0002ejspForm2_jsp_22.java:192: Missing term.
out.write("\" \t\t\t\tvalue=\"");
^
D:\jakarta\tomcat\work\localhost_8080%2Fexamples\_0002fjsp_0002fserstar_0002
fForm_00032_0002ejspForm2_jsp_22.java:216: Missing term.
out.write("\" \t\t\t\tvalue=\"");
^
D:\jakarta\tomcat\work\localhost_8080%2Fexamples\_0002fjsp_0002fserstar_0002
fForm_00032_0002ejspForm2_jsp_22.java:240: Missing term.
out.write("\" \t\t\t\tvalue=\"");
^
D:\jakarta\tomcat\work\localhost_8080%2Fexamples\_0002fjsp_0002fserstar_0002
fForm_00032_0002ejspForm2_jsp_22.java:264: Missing term.
out.write("\" \t\t\t\tvalue=\"");
^
D:\jakarta\tomcat\work\localhost_8080%2Fexamples\_0002fjsp_0002fserstar_0002
fForm_00032_0002ejspForm2_jsp_22.java:288: Missing term.
out.write("\" \t\t\t\tvalue=\"");
^
D:\jakarta\tomcat\work\localhost_8080%2Fexamples\_0002fjsp_0002fserstar_0002
fForm_00032_0002ejspForm2_jsp_22.java:312: Missing term.
out.write("\" \t\t\t\tvalue=\"");
^
D:\jakarta\tomcat\work\localhost_8080%2Fexamples\_0002fjsp_0002fserstar_0002
fForm_00032_0002ejspForm2_jsp_22.java:336: Missing term.
out.write("\" \t\t\t\tvalue=\"");
^
D:\jakarta\tomcat\work\localhost_8080%2Fexamples\_0002fjsp_0002fserstar_0002
fForm_00032_0002ejspForm2_jsp_22.java:360: Missing term.
out.write("\" \t\t\t\tvalue=\"");
^
D:\jakarta\tomcat\work\localhost_8080%2Fexamples\_0002fjsp_0002fserstar_0002
fForm_00032_0002ejspForm2_jsp_22.java:384: Missing term.
out.write("\" \t\t\t\tvalue=\"");
^
D:\jakarta\tomcat\work\localhost_8080%2Fexamples\_0002fjsp_0002fserstar_0002
fForm_00032_0002ejspForm2_jsp_22.java:408: Missing term.
out.write("\" \t\t\t\tvalue=\"");
^
D:\jakarta\tomcat\work\localhost_8080%2Fexamples\_0002fjsp_0002fserstar_0002
fForm_00032_0002ejspForm2_jsp_22.java:432: Missing term.
out.write("\" \t\t\t\tvalue=\"");
^
D:\jakarta\tomcat\work\localhost_8080%2Fexamples\_0002fjsp_0002fserstar_0002
fForm_00032_0002ejspForm2_jsp_22.java:456: Missing term.
out.write("\" \t\t\t\tvalue=\"");
^
D:\jakarta\tomcat\work\localhost_8080%2Fexamples\_0002fjsp_0002fserstar_0002
fForm_00032_0002ejspForm2_jsp_22.java:480: Missing term.
out.write("\" \t\t\t\tvalue=\"");
^
D:\jakarta\tomcat\work\localhost_8080%2Fexamples\_0002fjsp_0002fserstar_0002
fForm_00032_0002ejspForm2_jsp_22.java:504: Missing term.
out.write("\" \t\t\t\tvalue=\"");
^
D:\jakarta\tomcat\work\localhost_8080%2Fexamples\_0002fjsp_0002fserstar_0002
fForm_00032_0002ejspForm2_jsp_22.java:528: Missing term.
out.write("\" \t\t\t\tvalue=\"");
^
D:\jakarta\tomcat\work\localhost_8080%2Fexamples\_0002fjsp_0002fserstar_0002
fForm_00032_0002ejspForm2_jsp_22.java:552: Missing term.
out.write("\" \t\t\t\tvalue=\"");
^
D:\jakarta\tomcat\work\localhost_8080%2Fexamples\_0002fjsp_0002fserstar_0002
fForm_00032_0002ejspForm2_jsp_22.java:576: Missing term.
out.write("\" \t\t\t\tvalue=\"");
^
D:\jakarta\tomcat\work\localhost_8080%2Fexamples\_0002fjsp_0002fserstar_0002
fForm_00032_0002ejspForm2_jsp_22.java:600: Missing term.
out.write("\" \t\t\t\tvalue=\"");
^
D:\jakarta\tomcat\work\localhost_8080%2Fexamples\_0002fjsp_0002fserstar_0002
fForm_00032_0002ejspForm2_jsp_22.java:645: Missing term.
out.write("\"value=\"");
^
D:\jakarta\tomcat\work\localhost_8080%2Fexamples\_0002fjsp_0002fserstar_0002
fForm_
20 errors
at org.apache.jasper.compiler.Compiler.compile(Compiler.java,
Compiled Code)
at org.apache.jasper.runtime.JspServlet.loadJSP(JspServlet.java:413)
at
org.apache.jasper.runtime.JspServlet$JspServletWrapper.loadIfNecessary(JspSe
rvlet.java:149)
at
org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.ja
va:161)
at
org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
at org.apache.jasper.runtime.JspServlet.service(JspServlet.java,
Compiled Code)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java,
Compiled Code)
at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:160)
at
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338
)
at java.lang.Thread.run(Unknown Source)
Jos� Euclides J�nior
__________________________________
E-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
http://euclides.8m.com
If i fail, if i succeed, at least i live as i believe.
-----BEGIN PGP SIGNATURE-----
Version: PGP 6.5.1
iQCVAwUBOiUoUd0YhuJ3BUxtAQH9BQP+KiLFbn+L8dcWaFXtFfWUCgebRu2aQ7/R
9GQBhToxVXq194H+hKcJ3UFsU3nx9IpFCETfAdS8Sy3yF+be/b7slHkoh3LUHCys
WfBVyRoH6yOs3tUSxJuAPtuGmO6fmEGVhYtdrlVPoInUeif50KACKabPP05mfAmA
PyGRuuMCoSw=
=r1tc
-----END PGP SIGNATURE-----
Help me, PLEASE! Tomcat X multipart-form/data
Jose Euclides da Silva Junior - DIGR.O Wed, 29 Nov 2000 05:01:31 -0800
