image upload

hello

I read a file from the request object (myImage.jpg) to save it on the server

of my web application

thats is ok and works fine

after upload and write the file on the server Itry to diplay the uploaded image one see image with very very bad qulity

what shoud be the problem

[353 byte] By [the_Orienta] at [2007-11-27 0:15:31]
# 1
any help
the_Orienta at 2007-7-11 22:02:28 > top of Java-index,Java Essentials,Java Programming...
# 2
please help what shod be the problem
the_Orienta at 2007-7-11 22:02:28 > top of Java-index,Java Essentials,Java Programming...
# 3

Eh. Maybe you could post a bit of the code that you suspect is giving you problems.

Java's pretty good about not losing any data, but some methods of transport are more robust than others.

Of course, it could be an issue with whatever software is displaying the image. You haven't included enough information to really troubleshoot.

Joe H.

Joe_ha at 2007-7-11 22:02:28 > top of Java-index,Java Essentials,Java Programming...
# 4

here is the code

public void doUpload(HttpServletRequest request)

{

try

{

setSavePath(request.getSession().getServletContext().getRealPath("/")+"\\tempData\\");

ServletInputStream in = request.getInputStream();

byte[] line = new byte[128];

int i = in.readLine(line, 0, 128);

if (i < 3) return;

int boundaryLength = i - 2;

String boundary = new String(line, 0, boundaryLength); //-2 discards the newline character

fields = new Hashtable();

while (i != -1) {

String newLine = new String(line, 0, i);

setContentType(new String(line, 0, i-2));

if (newLine.startsWith("Content-Disposition: form-data; name=\"")) {

if (newLine.indexOf("filename=\"") != -1) {

setFilename(new String(line, 0, i-2));

if (filename==null || filename.equalsIgnoreCase("") || filename.equalsIgnoreCase(" ") || filename.length()< 1)

return;

//this is the file content

i = in.readLine(line, 0, 128);

//setContentType(new String(line, 0, i-2));

i = in.readLine(line, 0, 128);

// blank line

i = in.readLine(line, 0, 128);

newLine = new String(line, 0, i);

String IDmod = "";

int _x_ = app.org.AppConstants.AdID.indexOf("_");

PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter((savePath==null? "" : savePath) + filename)));

while (i != -1 && !newLine.startsWith(boundary)) {

i = in.readLine(line, 0, 128);

if ((i==boundaryLength+2 || i==boundaryLength+4) // + 4 is eof

&& (new String(line, 0, i).startsWith(boundary)))

pw.print(newLine.substring(0, newLine.length()-2));

else

pw.print(newLine);

newLine = new String(line, 0, i);

}

pw.close();

}

...................

can man here usee ImageInputStream an who

thanks

the_Orienta at 2007-7-11 22:02:28 > top of Java-index,Java Essentials,Java Programming...
# 5
any idea that help to find solution thanks
the_Orienta at 2007-7-11 22:02:28 > top of Java-index,Java Essentials,Java Programming...