Subject | Picture Servlet Problems possibly OT |
---|---|
Author | William L. Thomson Jr. |
Post date | 2003-06-05T17:23:48Z |
I am trying to track down a problem I am having with a servlet that
servers pictures from Blob columns in a Firebird DB.
The same servlet does not generate the same results on different
platforms.
The db server is the same for all machines. My DB server currently is a
RH 8 box, with a 2.4 kernel, and UTF8 as it's default character set.
My DB's default character set is ASCII. I choose that a long time ago
and plan to pump out the data into a UTF8 db. Hopefully that day is not
today.
The servlet only produces the expected output on one of my machines.
That machines is running a 2.2 kernel, and the OS is based on RH 6.2.
It's default character set is ISO8859-1.
Now I have two other machines that I have the same servlet talking to
the same db server, yet the output of the servlet differs.
One of the machines is a RH 9 box, with a 2.4 kernel and it's default
character set is UTF8.
Another machine is a Win2k machine. Not sure on default character set,
but I think it is UTF8?
Now one all three machines I am running the latest version of Tomcat,
JDK from Sun, and JayBird.
I have spent some time on this and for the life of me can't find the
problem. I have played around with the servlet itself, but I do not
think that is the problem.
I think the problem is created during the conversion of character sets.
I have tried to play around with the lc_ctype, but it seems to have no
effect.
I do not believe this is a Tomcat issue, maybe JDK? I do not think it's
a JayBird or Firebird problem. I do think I am not doing something
correctly with regard to Firebird, Jaybird and character sets.
Here is the main part of the servlet
if(result_set.next()) {
//ServletOutputStream sos = response.getOutputStream();
//sos.println(result_set.getString(1));
//sos.close();
PrintWriter print_writer = response.getWriter();
response.setContentType("image/jpeg");
response.setContentLength(result_set.getString(1).length());
print_writer.print(result_set.getString(1));
print_writer.close();
}
Now when I use ServletOutputStream, it sort of confirms my character set
theory. Since I get errors like
java.io.CharConversionException: Not an ISO 8859-1 character: �
Now if I change the character set of the browser to UTF8 I get the
following
java.io.CharConversionException: Not an ISO 8859-1 character: �
That last char shows up as a box on Win2k.
Now on both my Linux machines I am also using Apache. However on the
Windows machines I am only using Tomcat.
So my problem appears to be with character set conversions. I assume
between the output from Jaybird and the viewers browser? Possible having
to do with Tomcat?
Here are links to the output of the servlet on different machines when
using PrintWriter.
Here is a picture from the servlet on my production server
http://www.obsidian-studios.com/Picture1.jpg
Here is that same picture from my development machine and win2k machine.
http://www.obsidian-studios.com/Picture.jpg
It appears the pictures are off by one byte. However if you look at the
two files with a hex editor, their contents are quite different. More
than just a lack of a byte. Thus the result being a crappy picture.
Any suggestions on how I might solve this problem?
I am sort of stuck, and really need assistance. Thank you.
--
Sincerely,
William L. Thomson Jr.
Support Group
Obsidian-Studios, Inc.
3548 Jamestown Ln.
Jacksonville, FL 32223
Phone/Fax 904.260.2445
http://www.obsidian-studios.com
servers pictures from Blob columns in a Firebird DB.
The same servlet does not generate the same results on different
platforms.
The db server is the same for all machines. My DB server currently is a
RH 8 box, with a 2.4 kernel, and UTF8 as it's default character set.
My DB's default character set is ASCII. I choose that a long time ago
and plan to pump out the data into a UTF8 db. Hopefully that day is not
today.
The servlet only produces the expected output on one of my machines.
That machines is running a 2.2 kernel, and the OS is based on RH 6.2.
It's default character set is ISO8859-1.
Now I have two other machines that I have the same servlet talking to
the same db server, yet the output of the servlet differs.
One of the machines is a RH 9 box, with a 2.4 kernel and it's default
character set is UTF8.
Another machine is a Win2k machine. Not sure on default character set,
but I think it is UTF8?
Now one all three machines I am running the latest version of Tomcat,
JDK from Sun, and JayBird.
I have spent some time on this and for the life of me can't find the
problem. I have played around with the servlet itself, but I do not
think that is the problem.
I think the problem is created during the conversion of character sets.
I have tried to play around with the lc_ctype, but it seems to have no
effect.
I do not believe this is a Tomcat issue, maybe JDK? I do not think it's
a JayBird or Firebird problem. I do think I am not doing something
correctly with regard to Firebird, Jaybird and character sets.
Here is the main part of the servlet
if(result_set.next()) {
//ServletOutputStream sos = response.getOutputStream();
//sos.println(result_set.getString(1));
//sos.close();
PrintWriter print_writer = response.getWriter();
response.setContentType("image/jpeg");
response.setContentLength(result_set.getString(1).length());
print_writer.print(result_set.getString(1));
print_writer.close();
}
Now when I use ServletOutputStream, it sort of confirms my character set
theory. Since I get errors like
java.io.CharConversionException: Not an ISO 8859-1 character: �
Now if I change the character set of the browser to UTF8 I get the
following
java.io.CharConversionException: Not an ISO 8859-1 character: �
That last char shows up as a box on Win2k.
Now on both my Linux machines I am also using Apache. However on the
Windows machines I am only using Tomcat.
So my problem appears to be with character set conversions. I assume
between the output from Jaybird and the viewers browser? Possible having
to do with Tomcat?
Here are links to the output of the servlet on different machines when
using PrintWriter.
Here is a picture from the servlet on my production server
http://www.obsidian-studios.com/Picture1.jpg
Here is that same picture from my development machine and win2k machine.
http://www.obsidian-studios.com/Picture.jpg
It appears the pictures are off by one byte. However if you look at the
two files with a hex editor, their contents are quite different. More
than just a lack of a byte. Thus the result being a crappy picture.
Any suggestions on how I might solve this problem?
I am sort of stuck, and really need assistance. Thank you.
--
Sincerely,
William L. Thomson Jr.
Support Group
Obsidian-Studios, Inc.
3548 Jamestown Ln.
Jacksonville, FL 32223
Phone/Fax 904.260.2445
http://www.obsidian-studios.com