• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to know img tag src attribute loaded completely by action

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my Javascript I set img tag's src attribute using action:

function setTheater(){
(document.getElementById('codeword0')).src = 'theator.do';
(document.getElementById('codeword1')).src = 'theator.do';
}

Is there any way to make sure that another action do not execute before the first image completely loaded by the first action?
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the first action and the second action?

You probaly want onload and onerror events.



Eric
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm curious why you *care* about making them mutually exclusive.
 
kavin clain
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks to both of you for your support. With some efforts I solved the problem.


Actually I was calling theator.do action to load img tag.
At the time of streaming the image: the action class saves associated(to image) character in character array.
And the character array is one stored in session.


when my javascript...

...executes one by one, then the associated action classes threads executes in a random fashion.
This caused the skipping of few of the character in the character array.

I solved the problem by invoking consecutive action call when previous img tag is loaded.

Thank you.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why not just fix the real problem and not store it in session? Why wouldn't you store it in a local variable and stream that?
 
kavin clain
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The characters I store in character array is something I want to hide from the user.
I cannot expose it. That is why I saved it in session.

Every thing working fine because now I am calling consecutive actions to access images
only when the previous img tag is loaded using the onload function.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Er, a local variable in a servlet/action *is* hidden from the user, so your explanation makes little sense to me. And "hiding it from the user" makes no sense, since you're displaying the contents of the byte array--it's the image. Whatever.
 
kavin clain
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have two constant arrays... one holds the chars that I want to hide from the user,
and another array for holding the image paths.

I want to show images saved in path-relative-to-the-application.
So get those images & stream those to output. At the same time
save the char associated with the image.

Because the servlet/action thread ends & another action request when made the same thing repeats.
To recognize the user's char-array, save it in session & retrieve on next action request from the user.

I want to show the images & store the associated chars without being noticed by users.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I honestly don't understand what you think you're doing. Nothing on the server side is visible to users unless you deliberately expose it. The image is going to the user: there's no reason to put anything in session; all you need to do is stream the image bytes to the client. Session has nothing to do with that whatsoever. Look at any image-streaming servlet: the session is completely uninvolved. There's no reason to do this synchronously (and reasons *not* to).
 
kavin clain
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I inappropriately used the word 'hide'.

What I assume I can send one image at a time using a servlet/action.
I want one character associated with the image to store somewhere,
so that I can hold all characters all together in a sequence to use it later for decision making.

I expect a response from user which is based on images.
Then I cross check the response with my stored characters.

The images is like puzzle and characters are like solution.

Action class creates threads for each request from different users.
I store character sequence in session & fetch the one for the user to update it.
I call five requests for five img tags for each user.
The images are stored in WEB-INF sub directory.
Because I can't allow users to see the image path.(Application's need)
In servlet/action I set response.setHeader("Cache-Control", "no-cache");
JavaScript stores image one by one in img.src using action.do.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh, you're doing a captcha. I still wouldn't do it like that, but I understand now.
 
kavin clain
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Splitting it up into multiple images will make it even easier for a bot to break it.

Eric
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm, interesting point, especially if it's a fixed number of images.
 
kavin clain
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the actual implementation the the number of images vary between 5 to 8.

Before all images loaded the style:class is visibility:hidden & when all loaded then only the visibility:visible.
When loading I show a preloader.

The character array length is controlled from server & on form submission the characters are cross checked.
If not matched the form will be shown with new image array.

There are hundreds of images which when rendered appears as one image.
The style of the images are one on Yahoo signup page: "images stick to each other & quite shaky".
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It appears as one image but it is multiple images. All someone has to do is record the images manually and do a comparison. This is not hard to crack.

Eric
 
What's a year in metric? Do you know this metric stuff tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic