Using myfaces tomahawk inputFileUpload componet

I am using myfaces tomahawk inputFileUpload componet for the following requirement

1. I need to upload images to my user profile page.

2. Resize the image to fit my desired image size to be shown on the page

Promblems

1. The file i upload is done fine and images also show but

the image is stored or refrenced to the local machine , so if i delete or change file location the image dosent show.

what i need is to store the images in a seperate folder on the server or any other place and image should point to that location.

2. Now the image uploaded displayed using jsf's

<h:graphicImage url="fileupload_showimg.faces"/>

component where "fileupload_showimg.faces"

is a jsp page containing the following code

which is a scriplet

<%@ page import="java.io.File,

java.io.InputStream,

java.io.FileInputStream,

java.io.OutputStream"%><%@ page session="false" %><%

String contentType = (String)application.getAttribute("fileType");

String fileName = (String)application.getAttribute("fileName");

String allowCache = request.getParameter("allowCache");

String openDirectly = request.getParameter("openDirectly");

if(allowCache ==null || allowCache.equalsIgnoreCase("false"))

{

response.setHeader("pragma","no-cache");

response.setHeader("Cache-control","no-cache, no-store, must-revalidate");

response.setHeader("Expires","01 Apr 1995 01:10:10 GMT");

}

if(contentType!=null)

{

response.setContentType(contentType);

}

if(fileName !=null)

{

fileName = fileName.substring(fileName.lastIndexOf('\\')+1);

fileName = fileName.substring(fileName.lastIndexOf('/')+1);

StringBuffer contentDisposition =new StringBuffer();

if(openDirectly==null || openDirectly.equalsIgnoreCase("false"))

{

contentDisposition.append("attachment;");

}

contentDisposition.append("filename=\"");

contentDisposition.append(fileName);

contentDisposition.append("\"");

response.setHeader ("Content-Disposition", contentDisposition.toString());

}

byte[] bytes = (byte[])application.getAttribute("fileSizeBytes");

if (bytes !=null)

{

response.getOutputStream().write(bytes);

}

%>

works fine but the image shown in its original size most of the time very large.

I tried to fix the image size by changing the code to

<h:graphicImage url="fileupload_showimg.faces" width="300" height="500"/>

But now the image is shown is deformed

i need it to be fixed in size and not deformed

[4048 byte] By [Yashua] at [2007-11-27 4:03:51]
# 1
me again I think the first part of the problem is been solved nowthe 2nd problem is still there hope i can fix that also
Yashua at 2007-7-12 9:08:40 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...