Just carry the path of the file, not the image itself. When you submit the form you can get at that information (I believe, if not just grab it via JavaScript on the form submission and stick it in a hidden field). Then, when yout next JSP executes, you have the path to the file and you construct the img path:

<img src="<%="file://"+myForm.getPathToImageUserSelected()$>">

Something like that. The basic idea is that the JSP you send back as a result of the form submission is displaying the image from the user's PC, not your server. You just need to append the file:// part of the image's URI at some point.

--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

uma.k wrote:
Hi Frank,
Thanks for the reply. Your solution works good if I have to show preview in
the same page but I what if I need to show preview in the next JSP? How do I
carry the values/images?

Uma

-----Original Message-----
From: Frank W. Zammetti [mailto:[EMAIL PROTECTED]
Sent: Friday, December 17, 2004 10:44 PM
To: Struts Users Mailing List
Subject: Re: Preview of an Image and text


You might consider doing it all on the client...

<html>
<head>
<title>test</title>
<script>
function preview() {
lyrPreview.innerHTML = "";
lyrPreview.innerHTML += "Some message text...<br>";
lyrPreview.innerHTML += "<img src=\"file://" + theForm.theFile.value +
"\">";
}
</script>
</head>
<body>
Select file, then click button to preview:<br>
<form name="theForm">
<input type="file" name="theFile">
<input type="button" onClick="preview();" value="Preview message">
</form>
<br><br>
<u>Preview:</u><br><br>
<span id="lyrPreview"></span>
</body>
</html>

Works on IE, can't say whether it does on anything else.  Of course,
this will only work if you have enough information to construct the
complete preview on the client at that point, but you could
alternatively submit the form, then in the reply construct the file://
reference to the image as I've done above.  That would probably give you
the best of both worlds, and also remove any cross-browser concerns.
But, if you can do it without touching the server, so much the better I
figure.

--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

uma.k wrote:

Hi,
I have a form where the user is given the option to select a file to
upload(normally gif or jpg) before the user submits the file to the

server,

I wanted to show him a preview of his message and image.

How do I do that? Where do I store the image temporarly?

Any solutions?

Uma


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]










--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]









---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to