This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Tell us what you want to do exactly. Can the current page be replaced by the image? Do you want to open the image in a new window (or tab)? Do you want to include the image in your current page? Can the current page be refreshed?
1) use a simple &;t'a href="my_image.png">Click here for my image!
2) use a simple &;t'a href="my_image.png" target="_blank">Click here for my image!
3+4) use JavaScript (setting the src attribute of the image element) if you don't want to refresh the page, or a form with submitting if refreshing is allowed
I'm thinking the JSP part is actually irrelevant; it seems to be mostly about HTML and maybe a bit of JavaScript. Moving to the HTML / JavaScript forum.
thanks a lot bro for your help.. actually i am new to java.. not very familiar with images.. can you explain how to fetch an image placed in a directory...?
Creating an image element on the fly may be quite hard. Not the creating itself, but the placing etc.
Instead, why not create an image element which you initially hide:
With JavaScript, you can then change the image source and unhide it:
The order of these two changes is important; if you unhide it first the bogus image (or lack thereof) is shown.
Of course the image will need to be loaded so it may take sometime. Therefore, perhaps you can use an empty, transparant (GIF) image initially (instead of "dont_really_care_since_were_not_using_it_anyway"). It won't show up as a red cross (meaning image cannot be found), but still show nothing while the new image is loading.
myeclipse6.5 is showing "invalid escape sequence in the line 3" i.e it is showing error in the path. but path is ok.. what should i do..? and is this code sufficient to load an image on a JSP.?
Why do you have the JavaScript code in a Java scriptlet? If you do not know the difference between JavaScript, Java and Java scriptlets, you need to back up a bit and learn the difference.
Nothing we are talking here needs Java. No Java scriptlets. No JSP. No java. This is all client-side JavaScript. It can appear within a JSP, but does not need any server-side mechanisms.