File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes thumbanil to larger version of image  using java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "thumbanil to larger version of image  using java" Watch "thumbanil to larger version of image  using java" New topic
Author

thumbanil to larger version of image using java

Sujatha Kalluri
Ranch Hand

Joined: Oct 09, 2002
Posts: 33
Hello,

I have problem in opening the new window in javascript in javascript using window.open(url, windowname, etc..), the url is broken.

when I click on thumbnail image, I have to show the larger version of image,

my image path goes like this...
a href ="javascript:myPopup("//shor/project/webapp/images/beach.jpg", "somename")>


so... my images are to be fetched from folder, when I am passing them to javascript function



the url when printed in javascript function is not as original one but is coming out as /shorprojectwebappimagesbeach.jpg, path is broken, thus in new window it is telling could not find resource.

how do I get original path in javascript.. if it is not possible with javascript, how do I do in java, I wanted to use javascript instead of directly opening image from because in the new window I dont want to have menu bar, tool bar, directories etc, is it possible to do that in java itself ie opening a new window without having menu bar, tool bar etc. By the way I have set of images that needs to be fetched from folder, so my logic is in for loop , not just one image.

thanks in advance for any help,
Sujatha.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18825
    
  40


This forum is for Java -- not JavaScript.

Moving this topic to the Javasciprt forum.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

> //shor/project/webapp/images/beach.jpg

The URL you need to pass can't be the the real URL on the web server, but had to be the URL that the JPG would be accessed from the client. For example, if the web site is:
http://www.mysite.net/shorProject/
The the URL you might want to pass would be:
http://www.mysite.net/shorProjects/images/becah.jpg

Remember that the Javascript popup is run on the client machine, not the server. So the client doesn't have a shor/project.webapp/images/beach.jpg. The client only has access to the website, so the image needs to be in a publicly accessible directory and referenced via the web-sites URL to that location.


Steve
Sujatha Kalluri
Ranch Hand

Joined: Oct 09, 2002
Posts: 33
HI,

to correct my previous thread... the images I am getting are not from webapp folder... but it is some network folder

say....//shor/images/inputimages/beach.jpg.

how do I access network folder in javascript.

if it is not possible can I do it java. my criteria is my new window should not have directories.menubar, toolbar etc.

thanks

Sujatha.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61193
    
  66

If the image is not web-accessible then it cannot be accessed by URL, using JavaScript or any other technique.

You'll need to address a servlet that reads the image from the file system and streams it as the response.

Do a search on the Servlets forum -- this has been addressed many times.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sujatha Kalluri
Ranch Hand

Joined: Oct 09, 2002
Posts: 33
if is working why canot it work with <a windowname...) <br /> where url is "//shor/images/inputimages/beach.jpg. <br /> <br /> why cant we use file system call in a href. <br /> <br /> Sujatha. rel="nofollow">
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61193
    
  66

Sujatha Kalluri wrote:why cant we use file system call in a href.

You can answer your own question by thinking about the answer to this question:

Where and when is the href evaluated?
Sujatha Kalluri
Ranch Hand

Joined: Oct 09, 2002
Posts: 33
Hi,

this is working for me when I used escape() function to url before sending to javascript and using unescape(url) in window.open of javascript.

also since backslash is escape character in string literal.. I used java regular expression to replace each backslash to double backslash. then I used escape() to send to javascript.

Sujatha.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61193
    
  66

Answer this question: will it work when the browser is running on a machine that does not have the network share mapped?

In other words, no, it is not fixed yet.
Sujatha Kalluri
Ranch Hand

Joined: Oct 09, 2002
Posts: 33
In my case.. it is working since client is on same machine as server, as you said if it doesn't have mapped network drive.. it will not work..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: thumbanil to larger version of image using java