Re: multithreaded with taglibs

2007-11-29 Thread ben short
Do you really need to use tomcat to do this? Maybe you should take a
step back and rethink what your trying to achieve.

On Nov 29, 2007 10:14 AM, Yair Ben-Meir [EMAIL PROTECTED] wrote:
 Let me try another scenario: let say that the generated text for the out
 is not one iamge, but some number between 0 and 5. the correct number of
 images will be clear only after the execution of the thread. In this case, I
 do want to continue with the JSP and write to the out later on.
 The only think I thought of was to write something like {1} (instead of
 tag) and when the page is over it will replace {1} with the right code
 from the thread. This will require me to get the generated page from the JSP
 and manipulate it after Jasper has finished with it.
 Any better way to do it?

 -Original Message-
 From: Christopher Schultz [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, November 28, 2007 7:04 PM
 To: Tomcat Users List
 Subject: Re: multithreaded with taglibs


 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Yair,

 Yair Ben-Meir wrote:
  This solution is good but we must write to the out of the jsp before the
  thread is running (we bypass this because the thread will write to a
  pre-decided file name). is there another way to do it, without writing to
  the out?

 I'm not sure I understand what you mean. Are you asking how to continue
 evaluating the JSP while the image is being generated? Easy. Create a
 class like this:

 public class ParallelImageGenerator
 {
 public ParallelImageGenerator() { ... }

 public String getGeneratedFilename() { ... }

 public void start() { ... }
 public void wait() { ... }
 }

 Then, from your tagStart method in your custom tag library, do something
 like this:

 pig = new ParallelImageGenerator();
 pig.start();

 jspOut.print(img src=\ + pig.getGeneratedFilename() + \ /);

 // Register the 'pig' object somewhere so you can go back and wait
 // on all of the image generators.

 - -chris

 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.7 (MingW32)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

 iD8DBQFHTZ9n9CaO5/Lv0PARAkxKAKCP/PK410pUbBTrWxS9G5fIhE6aYgCfb6dJ
 0RnxBh6+CfToeccD3lgS/6M=
 =Iksk
 -END PGP SIGNATURE-

 -
 To start a new topic, e-mail: users@tomcat.apache.org
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



 -
 To start a new topic, e-mail: users@tomcat.apache.org
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: multithreaded with taglibs

2007-11-29 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Yair,

Yair Ben-Meir wrote:
 Let me try another scenario: let say that the generated text for the out
 is not one iamge, but some number between 0 and 5. the correct number of
 images will be clear only after the execution of the thread. In this case, I
 do want to continue with the JSP and write to the out later on.
 The only think I thought of was to write something like {1} (instead of
 tag) and when the page is over it will replace {1} with the right code
 from the thread. This will require me to get the generated page from the JSP
 and manipulate it after Jasper has finished with it.

This will require you to write a body tag (or whatever they're
called). I haven't written a tag library in 7 years. :(

Basically, you'll have to keep all the template content somewhere so you
can manipulate it /after/ the threads are done, but before the output is
written. Using a wrapper tag (like parallelimgimgimg/parallel)
will help here because you can collect all the jobs to be done (each img
is a job), run them all in parallel, wait for them all to finish, and
then generate all the relevant (real) content to the output stream.

Another option is to simply do all this work before you start generating
any output, which would be my preference. Have the request invoke a
servlet that does everything and then writes the output using JSP. Much
easier and cleaner, which is why it's been the recommended technique
since two days after JSP was invented.

- -chris

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHTuq49CaO5/Lv0PARAtouAKCq4/Fl/+MEsXILwECGVMQ4QyqP1ACgjFTG
qSxP8arHfrjmAbj+CHEtns4=
=ohP6
-END PGP SIGNATURE-

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: multithreaded with taglibs

2007-11-28 Thread Yair Ben-Meir
Sorry chris, I didn't understand u then... it is a good solution (great
minds think alike!).

This solution is good but we must write to the out of the jsp before the
thread is running (we bypass this because the thread will write to a
pre-decided file name). is there another way to do it, without writing to
the out?
I guess not, I m just checking that I m not missing something.

Thanks
Yair


-Original Message-
From: Christopher Schultz [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, November 27, 2007 6:17 PM
To: Tomcat Users List
Subject: Re: multithreaded with taglibs

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Yair,

Yair Ben-Meir wrote:
 Btw - i thought of something: maybe the img tag will run a thread, return
an
 outout to the page with some new image name, and release the jsp to
 continue. The thread will do the work and save the new image under the
name
 the tag returned to the page. At the end of the page, a wait tag will be
 for waiting to whole of the threads to finish. That's the best thing I
 thought of till now.

That's exactly what I was suggesting.

- -chris

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHTELo9CaO5/Lv0PARAg3oAJ45nSggqD5/U92iGMUX8ZqexbMhNACgv3lD
Oun0j/lB3Xa2CmnTVrC14BM=
=uTJw
-END PGP SIGNATURE-

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: multithreaded with taglibs

2007-11-28 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Yair,

Yair Ben-Meir wrote:
 This solution is good but we must write to the out of the jsp before the
 thread is running (we bypass this because the thread will write to a
 pre-decided file name). is there another way to do it, without writing to
 the out?

I'm not sure I understand what you mean. Are you asking how to continue
evaluating the JSP while the image is being generated? Easy. Create a
class like this:

public class ParallelImageGenerator
{
public ParallelImageGenerator() { ... }

public String getGeneratedFilename() { ... }

public void start() { ... }
public void wait() { ... }
}

Then, from your tagStart method in your custom tag library, do something
like this:

pig = new ParallelImageGenerator();
pig.start();

jspOut.print(img src=\ + pig.getGeneratedFilename() + \ /);

// Register the 'pig' object somewhere so you can go back and wait
// on all of the image generators.

- -chris

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHTZ9n9CaO5/Lv0PARAkxKAKCP/PK410pUbBTrWxS9G5fIhE6aYgCfb6dJ
0RnxBh6+CfToeccD3lgS/6M=
=Iksk
-END PGP SIGNATURE-

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: multithreaded with taglibs

2007-11-27 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Yair,

Yair Ben-Meir wrote:
 Btw - i thought of something: maybe the img tag will run a thread, return an
 outout to the page with some new image name, and release the jsp to
 continue. The thread will do the work and save the new image under the name
 the tag returned to the page. At the end of the page, a wait tag will be
 for waiting to whole of the threads to finish. That's the best thing I
 thought of till now.

That's exactly what I was suggesting.

- -chris

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHTELo9CaO5/Lv0PARAg3oAJ45nSggqD5/U92iGMUX8ZqexbMhNACgv3lD
Oun0j/lB3Xa2CmnTVrC14BM=
=uTJw
-END PGP SIGNATURE-

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: multithreaded with taglibs

2007-11-26 Thread David Cassidy
Errr 

how will you allow people to access the file over the internet with a
file:// protocol ?

are you only running the app and the users browser on the same machine ?

file://C:\My Documents\image.gif 

?

Can't see that working over the internet


On Sun, 2007-11-25 at 13:56 +0200, Yair Ben-Meir wrote:
 Thanks, but that's not good for me, I need the page to be with a real file
 link (file://), not through a servlet.
 
 
 -Original Message-
 From: Pid [mailto:[EMAIL PROTECTED] 
 Sent: Sunday, November 25, 2007 11:53 AM
 To: Tomcat Users List
 Subject: Re: multithreaded with taglibs
 
 Yair Ben-Meir wrote:
  Let say that the tag will have to generate the image with a text given as
 an
  attribute, and it takes time so I want the page to continue:
  
  my:img src=file text=first/
  
  .
  
  my:img src=file text=first/
 
 Why are you doing this with a tag, rather than sending the parameter to
 a servlet that serves an image into it's output stream?
 
 You exploit the browsers own request handling capabilities this way.
 
 img src=/img-app/generate?param1=some+text+here alt=an image /
 
 
 p
 
 
 
  -Original Message-
  From: David Cassidy [mailto:[EMAIL PROTECTED] 
  Sent: Thursday, November 22, 2007 6:08 PM
  To: Tomcat Users List
  Subject: Re: multithreaded with taglibs
  
  Hi
  
  What is your tag going to produce ?
  is it an IMG SRC=. type tag ?
  
  or how are you allowing the browser to access the image ?
  
  Ta
  
  D
  
  On Thu, 2007-11-22 at 14:57 +0200, Yair Ben-Meir wrote:
  Hi
 
  Is there a way to write a taglib that will do a multithreading work?
  Meaning, that tomcatwill not wait till the first instance of the tag
  will end, and continue to the rest of the page, and maybe start with
  another instance, and than it will insert the result of each instance
  in the right place?
 
   
 
  Example:
 
  my:img name=/
 
  .
 
  my:img name=/
 
   
 
  And let say that each my:img is supposed to download the image and
  save it locally or something like that, and I don't want tomcat to
  wait till the first tag is finished.
 
   
 
   
 
  Thanks
 
   
 
   
 
  Yair Ben-Meir
 
   
 
  Office: 073-7997801
 
  Fax: 073-7997800
 
  Mob:   054-5769681
 
 
 
   
 
 
  
  
  -
  To start a new topic, e-mail: users@tomcat.apache.org
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  
  
  
  
  
  -
  To start a new topic, e-mail: users@tomcat.apache.org
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  
  
 
 
 -
 To start a new topic, e-mail: users@tomcat.apache.org
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 
 
 -
 To start a new topic, e-mail: users@tomcat.apache.org
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: multithreaded with taglibs

2007-11-26 Thread ben short
Yair,

I created a eshop website that dynamically re sizes images depending
on the url. Here is a simple outline of what happens.

A new product is created by the shop admin. Images are then uploaded
and stored in a database in the uploaded size.

When a product page is viewed the controller ( im using spring ) pulls
the product object from the db and passes it to the view, a jsp page.

The jsp then generates a image tag as show below.

img width=175px name=mainImage
src=productimages/69_s_medium.jpg title=Kitchen Stove and
Utensils/

The browser then renders the page, when it finds a image tag it then
uses another thread to load the image. this is standard browser
behavior.

The productimages url is mapped to another controller, that parses the
url. The first part of the url is the image id, the next part is tells
it that the part after that is a size rather than a dimension. The
controller knows the expected dimensions for a medium image.

The controller then pulls the image from the db and resizes it before
sending it to the browser. The controller is actually smarter than
that, and does on disk caching of resized images and check the last
mod time, but i wont detail that here.

So what is happening here is the browser is rendering the html created
by the jsp page and then making another request to get the images,
which is then making tomcat use another thread to generate the image.
Sound like what your trying to achieve?

Ben

On Nov 26, 2007 10:15 AM, David Cassidy [EMAIL PROTECTED] wrote:
 Errr

 how will you allow people to access the file over the internet with a
 file:// protocol ?

 are you only running the app and the users browser on the same machine ?

 file://C:\My Documents\image.gif

 ?

 Can't see that working over the internet



 On Sun, 2007-11-25 at 13:56 +0200, Yair Ben-Meir wrote:
  Thanks, but that's not good for me, I need the page to be with a real file
  link (file://), not through a servlet.
 
 
  -Original Message-
  From: Pid [mailto:[EMAIL PROTECTED]
  Sent: Sunday, November 25, 2007 11:53 AM
  To: Tomcat Users List
  Subject: Re: multithreaded with taglibs
 
  Yair Ben-Meir wrote:
   Let say that the tag will have to generate the image with a text given as
  an
   attribute, and it takes time so I want the page to continue:
  
   my:img src=file text=first/
  
   .
  
   my:img src=file text=first/
 
  Why are you doing this with a tag, rather than sending the parameter to
  a servlet that serves an image into it's output stream?
 
  You exploit the browsers own request handling capabilities this way.
 
  img src=/img-app/generate?param1=some+text+here alt=an image /
 
 
  p
 
 
 
   -Original Message-
   From: David Cassidy [mailto:[EMAIL PROTECTED]
   Sent: Thursday, November 22, 2007 6:08 PM
   To: Tomcat Users List
   Subject: Re: multithreaded with taglibs
  
   Hi
  
   What is your tag going to produce ?
   is it an IMG SRC=. type tag ?
  
   or how are you allowing the browser to access the image ?
  
   Ta
  
   D
  
   On Thu, 2007-11-22 at 14:57 +0200, Yair Ben-Meir wrote:
   Hi
  
   Is there a way to write a taglib that will do a multithreading work?
   Meaning, that tomcatwill not wait till the first instance of the tag
   will end, and continue to the rest of the page, and maybe start with
   another instance, and than it will insert the result of each instance
   in the right place?
  
  
  
   Example:
  
   my:img name=/
  
   .
  
   my:img name=/
  
  
  
   And let say that each my:img is supposed to download the image and
   save it locally or something like that, and I don't want tomcat to
   wait till the first tag is finished.
  
  
  
  
  
   Thanks
  
  
  
  
  
   Yair Ben-Meir
  
  
  
   Office: 073-7997801
  
   Fax: 073-7997800
  
   Mob:   054-5769681
  
  
  
  
  
  
  
  
   -
   To start a new topic, e-mail: users@tomcat.apache.org
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
  
  
  
   -
   To start a new topic, e-mail: users@tomcat.apache.org
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
 
 
  -
  To start a new topic, e-mail: users@tomcat.apache.org
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 
 
  -
  To start a new topic, e-mail: users@tomcat.apache.org
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 


 -
 To start a new topic, e-mail: users@tomcat.apache.org
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL

RE: multithreaded with taglibs

2007-11-26 Thread Yair Ben-Meir
You're right about that - it is not for using over the web. Anyway, that's
just an example. The main issue is to run the work of the tag in a thread
without making the rest of the page wait.

-Original Message-
From: David Cassidy [mailto:[EMAIL PROTECTED] 
Sent: Monday, November 26, 2007 12:15 PM
To: Tomcat Users List
Subject: RE: multithreaded with taglibs

Errr 

how will you allow people to access the file over the internet with a
file:// protocol ?

are you only running the app and the users browser on the same machine ?

file://C:\My Documents\image.gif 

?

Can't see that working over the internet


On Sun, 2007-11-25 at 13:56 +0200, Yair Ben-Meir wrote:
 Thanks, but that's not good for me, I need the page to be with a real file
 link (file://), not through a servlet.
 
 
 -Original Message-
 From: Pid [mailto:[EMAIL PROTECTED] 
 Sent: Sunday, November 25, 2007 11:53 AM
 To: Tomcat Users List
 Subject: Re: multithreaded with taglibs
 
 Yair Ben-Meir wrote:
  Let say that the tag will have to generate the image with a text given
as
 an
  attribute, and it takes time so I want the page to continue:
  
  my:img src=file text=first/
  
  .
  
  my:img src=file text=first/
 
 Why are you doing this with a tag, rather than sending the parameter to
 a servlet that serves an image into it's output stream?
 
 You exploit the browsers own request handling capabilities this way.
 
 img src=/img-app/generate?param1=some+text+here alt=an image /
 
 
 p
 
 
 
  -Original Message-
  From: David Cassidy [mailto:[EMAIL PROTECTED] 
  Sent: Thursday, November 22, 2007 6:08 PM
  To: Tomcat Users List
  Subject: Re: multithreaded with taglibs
  
  Hi
  
  What is your tag going to produce ?
  is it an IMG SRC=. type tag ?
  
  or how are you allowing the browser to access the image ?
  
  Ta
  
  D
  
  On Thu, 2007-11-22 at 14:57 +0200, Yair Ben-Meir wrote:
  Hi
 
  Is there a way to write a taglib that will do a multithreading work?
  Meaning, that tomcatwill not wait till the first instance of the tag
  will end, and continue to the rest of the page, and maybe start with
  another instance, and than it will insert the result of each instance
  in the right place?
 
   
 
  Example:
 
  my:img name=/
 
  .
 
  my:img name=/
 
   
 
  And let say that each my:img is supposed to download the image and
  save it locally or something like that, and I don't want tomcat to
  wait till the first tag is finished.
 
   
 
   
 
  Thanks
 
   
 
   
 
  Yair Ben-Meir
 
   
 
  Office: 073-7997801
 
  Fax: 073-7997800
 
  Mob:   054-5769681
 
 
 
   
 
 
  
  
  -
  To start a new topic, e-mail: users@tomcat.apache.org
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  
  
  
  
  
  -
  To start a new topic, e-mail: users@tomcat.apache.org
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  
  
 
 
 -
 To start a new topic, e-mail: users@tomcat.apache.org
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 
 
 -
 To start a new topic, e-mail: users@tomcat.apache.org
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: multithreaded with taglibs

2007-11-26 Thread Yair Ben-Meir
Hi ben
Thanks for your idea. In my case, I can't use it, since the generated img
tag must be a static file (a file: url) and not a link to a servlet. That's
why the processing must be when generating the html.
Thanks
Yair


-Original Message-
From: ben short [mailto:[EMAIL PROTECTED] 
Sent: Monday, November 26, 2007 1:19 PM
To: Tomcat Users List
Subject: Re: multithreaded with taglibs

Yair,

I created a eshop website that dynamically re sizes images depending
on the url. Here is a simple outline of what happens.

A new product is created by the shop admin. Images are then uploaded
and stored in a database in the uploaded size.

When a product page is viewed the controller ( im using spring ) pulls
the product object from the db and passes it to the view, a jsp page.

The jsp then generates a image tag as show below.

img width=175px name=mainImage
src=productimages/69_s_medium.jpg title=Kitchen Stove and
Utensils/

The browser then renders the page, when it finds a image tag it then
uses another thread to load the image. this is standard browser
behavior.

The productimages url is mapped to another controller, that parses the
url. The first part of the url is the image id, the next part is tells
it that the part after that is a size rather than a dimension. The
controller knows the expected dimensions for a medium image.

The controller then pulls the image from the db and resizes it before
sending it to the browser. The controller is actually smarter than
that, and does on disk caching of resized images and check the last
mod time, but i wont detail that here.

So what is happening here is the browser is rendering the html created
by the jsp page and then making another request to get the images,
which is then making tomcat use another thread to generate the image.
Sound like what your trying to achieve?

Ben

On Nov 26, 2007 10:15 AM, David Cassidy [EMAIL PROTECTED] wrote:
 Errr

 how will you allow people to access the file over the internet with a
 file:// protocol ?

 are you only running the app and the users browser on the same machine ?

 file://C:\My Documents\image.gif

 ?

 Can't see that working over the internet



 On Sun, 2007-11-25 at 13:56 +0200, Yair Ben-Meir wrote:
  Thanks, but that's not good for me, I need the page to be with a real
file
  link (file://), not through a servlet.
 
 
  -Original Message-
  From: Pid [mailto:[EMAIL PROTECTED]
  Sent: Sunday, November 25, 2007 11:53 AM
  To: Tomcat Users List
  Subject: Re: multithreaded with taglibs
 
  Yair Ben-Meir wrote:
   Let say that the tag will have to generate the image with a text given
as
  an
   attribute, and it takes time so I want the page to continue:
  
   my:img src=file text=first/
  
   .
  
   my:img src=file text=first/
 
  Why are you doing this with a tag, rather than sending the parameter to
  a servlet that serves an image into it's output stream?
 
  You exploit the browsers own request handling capabilities this way.
 
  img src=/img-app/generate?param1=some+text+here alt=an image /
 
 
  p
 
 
 
   -Original Message-
   From: David Cassidy [mailto:[EMAIL PROTECTED]
   Sent: Thursday, November 22, 2007 6:08 PM
   To: Tomcat Users List
   Subject: Re: multithreaded with taglibs
  
   Hi
  
   What is your tag going to produce ?
   is it an IMG SRC=. type tag ?
  
   or how are you allowing the browser to access the image ?
  
   Ta
  
   D
  
   On Thu, 2007-11-22 at 14:57 +0200, Yair Ben-Meir wrote:
   Hi
  
   Is there a way to write a taglib that will do a multithreading work?
   Meaning, that tomcatwill not wait till the first instance of the tag
   will end, and continue to the rest of the page, and maybe start with
   another instance, and than it will insert the result of each instance
   in the right place?
  
  
  
   Example:
  
   my:img name=/
  
   .
  
   my:img name=/
  
  
  
   And let say that each my:img is supposed to download the image and
   save it locally or something like that, and I don't want tomcat to
   wait till the first tag is finished.
  
  
  
  
  
   Thanks
  
  
  
  
  
   Yair Ben-Meir
  
  
  
   Office: 073-7997801
  
   Fax: 073-7997800
  
   Mob:   054-5769681
  
  
  
  
  
  
  
  
   -
   To start a new topic, e-mail: users@tomcat.apache.org
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
  
  
  
   -
   To start a new topic, e-mail: users@tomcat.apache.org
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
 
 
  -
  To start a new topic, e-mail: users@tomcat.apache.org
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED

RE: multithreaded with taglibs

2007-11-26 Thread Yair Ben-Meir
Well, the output of the jsp isn't html in my case, but something similar, an
xml file with references to other files.

-Original Message-
From: Pid [mailto:[EMAIL PROTECTED] 
Sent: Monday, November 26, 2007 1:48 PM
To: Tomcat Users List
Subject: Re: multithreaded with taglibs

ben's method does actually produce a static file I think, he's just
producing them on demand and delivering them via a servlet.

I'm curious, why does it have to be a static file, and why does it have
to be a local 'file:' based url?

p



Yair Ben-Meir wrote:
 Hi ben
 Thanks for your idea. In my case, I can't use it, since the generated img
 tag must be a static file (a file: url) and not a link to a servlet.
That's
 why the processing must be when generating the html.
 Thanks
 Yair
 
 
 -Original Message-
 From: ben short [mailto:[EMAIL PROTECTED] 
 Sent: Monday, November 26, 2007 1:19 PM
 To: Tomcat Users List
 Subject: Re: multithreaded with taglibs
 
 Yair,
 
 I created a eshop website that dynamically re sizes images depending
 on the url. Here is a simple outline of what happens.
 
 A new product is created by the shop admin. Images are then uploaded
 and stored in a database in the uploaded size.
 
 When a product page is viewed the controller ( im using spring ) pulls
 the product object from the db and passes it to the view, a jsp page.
 
 The jsp then generates a image tag as show below.
 
 img width=175px name=mainImage
 src=productimages/69_s_medium.jpg title=Kitchen Stove and
 Utensils/
 
 The browser then renders the page, when it finds a image tag it then
 uses another thread to load the image. this is standard browser
 behavior.
 
 The productimages url is mapped to another controller, that parses the
 url. The first part of the url is the image id, the next part is tells
 it that the part after that is a size rather than a dimension. The
 controller knows the expected dimensions for a medium image.
 
 The controller then pulls the image from the db and resizes it before
 sending it to the browser. The controller is actually smarter than
 that, and does on disk caching of resized images and check the last
 mod time, but i wont detail that here.
 
 So what is happening here is the browser is rendering the html created
 by the jsp page and then making another request to get the images,
 which is then making tomcat use another thread to generate the image.
 Sound like what your trying to achieve?
 
 Ben
 
 On Nov 26, 2007 10:15 AM, David Cassidy [EMAIL PROTECTED] wrote:
 Errr

 how will you allow people to access the file over the internet with a
 file:// protocol ?

 are you only running the app and the users browser on the same machine ?

 file://C:\My Documents\image.gif

 ?

 Can't see that working over the internet



 On Sun, 2007-11-25 at 13:56 +0200, Yair Ben-Meir wrote:
 Thanks, but that's not good for me, I need the page to be with a real
 file
 link (file://), not through a servlet.


 -Original Message-
 From: Pid [mailto:[EMAIL PROTECTED]
 Sent: Sunday, November 25, 2007 11:53 AM
 To: Tomcat Users List
 Subject: Re: multithreaded with taglibs

 Yair Ben-Meir wrote:
 Let say that the tag will have to generate the image with a text given
 as
 an
 attribute, and it takes time so I want the page to continue:

 my:img src=file text=first/

 .

 my:img src=file text=first/
 Why are you doing this with a tag, rather than sending the parameter to
 a servlet that serves an image into it's output stream?

 You exploit the browsers own request handling capabilities this way.

 img src=/img-app/generate?param1=some+text+here alt=an image /


 p



 -Original Message-
 From: David Cassidy [mailto:[EMAIL PROTECTED]
 Sent: Thursday, November 22, 2007 6:08 PM
 To: Tomcat Users List
 Subject: Re: multithreaded with taglibs

 Hi

 What is your tag going to produce ?
 is it an IMG SRC=. type tag ?

 or how are you allowing the browser to access the image ?

 Ta

 D

 On Thu, 2007-11-22 at 14:57 +0200, Yair Ben-Meir wrote:
 Hi

 Is there a way to write a taglib that will do a multithreading work?
 Meaning, that tomcatwill not wait till the first instance of the tag
 will end, and continue to the rest of the page, and maybe start with
 another instance, and than it will insert the result of each instance
 in the right place?



 Example:

 my:img name=/

 .

 my:img name=/



 And let say that each my:img is supposed to download the image and
 save it locally or something like that, and I don't want tomcat to
 wait till the first tag is finished.





 Thanks





 Yair Ben-Meir



 Office: 073-7997801

 Fax: 073-7997800

 Mob:   054-5769681







 -
 To start a new topic, e-mail: users@tomcat.apache.org
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]





 -
 To start a new topic, e-mail: users

Re: multithreaded with taglibs

2007-11-26 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Yair,

Yair Ben-Meir wrote:
 You're right about that - it is not for using over the web. Anyway, that's
 just an example. The main issue is to run the work of the tag in a thread
 without making the rest of the page wait.

I think you're hit the nail on the head right there: do the work in a
thread.

FWIW, I think this is an awful idea: if your page renders quickly, the
browser will attempt to load the images before your image threads have a
chance to actually generate the images. The only thing that /might/ work
is to do something like this:

imageHack:parallel
imageHack:image text=foo /
imageHack:image text=bar /
/imageHack:parallel

The parallel tag just sets up an environment for the sub tags. Each
sub tag registers a job with the parent. The end method for the
parallel tag starts one or more threads to actually create the images,
then calls join() on each one. This will allow the images to be
generated in parallel instead of serial order.

You can't close the output stream of the web page until all of the
images are created, otherwise you risk broken images showing up on the
page. If you don't wrap your image tags in some kind of wrapper
(parallel in my example), then you can't gather the threads in a sane
way in order to join() on them all.

Again, this sounds awful. Why not use http URLs instead of file urls?

- -chris

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHSxP89CaO5/Lv0PARAmDwAJ9zyDEq/U1LCIRnkLs69v+yMsxJrACgrULl
bH2y/sAsOyQ+IZUbw3aRIzM=
=wAKM
-END PGP SIGNATURE-

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: multithreaded with taglibs

2007-11-26 Thread Yair Ben-Meir
Thanks chris,
The generated output of the JSP is not html and not for an explorer...
that's why it has to be generated along the JSP work.

Btw - i thought of something: maybe the img tag will run a thread, return an
outout to the page with some new image name, and release the jsp to
continue. The thread will do the work and save the new image under the name
the tag returned to the page. At the end of the page, a wait tag will be
for waiting to whole of the threads to finish. That's the best thing I
thought of till now.
Thanks
Yair


-Original Message-
From: Christopher Schultz [mailto:[EMAIL PROTECTED] 
Sent: Monday, November 26, 2007 8:44 PM
To: Tomcat Users List
Subject: Re: multithreaded with taglibs

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Yair,

Yair Ben-Meir wrote:
 You're right about that - it is not for using over the web. Anyway, that's
 just an example. The main issue is to run the work of the tag in a thread
 without making the rest of the page wait.

I think you're hit the nail on the head right there: do the work in a
thread.

FWIW, I think this is an awful idea: if your page renders quickly, the
browser will attempt to load the images before your image threads have a
chance to actually generate the images. The only thing that /might/ work
is to do something like this:

imageHack:parallel
imageHack:image text=foo /
imageHack:image text=bar /
/imageHack:parallel

The parallel tag just sets up an environment for the sub tags. Each
sub tag registers a job with the parent. The end method for the
parallel tag starts one or more threads to actually create the images,
then calls join() on each one. This will allow the images to be
generated in parallel instead of serial order.

You can't close the output stream of the web page until all of the
images are created, otherwise you risk broken images showing up on the
page. If you don't wrap your image tags in some kind of wrapper
(parallel in my example), then you can't gather the threads in a sane
way in order to join() on them all.

Again, this sounds awful. Why not use http URLs instead of file urls?

- -chris

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHSxP89CaO5/Lv0PARAmDwAJ9zyDEq/U1LCIRnkLs69v+yMsxJrACgrULl
bH2y/sAsOyQ+IZUbw3aRIzM=
=wAKM
-END PGP SIGNATURE-

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: multithreaded with taglibs

2007-11-25 Thread Pid
Yair Ben-Meir wrote:
 Let say that the tag will have to generate the image with a text given as an
 attribute, and it takes time so I want the page to continue:
 
 my:img src=file text=first/
 
 .
 
 my:img src=file text=first/

Why are you doing this with a tag, rather than sending the parameter to
a servlet that serves an image into it's output stream?

You exploit the browsers own request handling capabilities this way.

img src=/img-app/generate?param1=some+text+here alt=an image /


p



 -Original Message-
 From: David Cassidy [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, November 22, 2007 6:08 PM
 To: Tomcat Users List
 Subject: Re: multithreaded with taglibs
 
 Hi
 
 What is your tag going to produce ?
 is it an IMG SRC=. type tag ?
 
 or how are you allowing the browser to access the image ?
 
 Ta
 
 D
 
 On Thu, 2007-11-22 at 14:57 +0200, Yair Ben-Meir wrote:
 Hi

 Is there a way to write a taglib that will do a multithreading work?
 Meaning, that tomcatwill not wait till the first instance of the tag
 will end, and continue to the rest of the page, and maybe start with
 another instance, and than it will insert the result of each instance
 in the right place?

  

 Example:

 my:img name=/

 .

 my:img name=/

  

 And let say that each my:img is supposed to download the image and
 save it locally or something like that, and I don't want tomcat to
 wait till the first tag is finished.

  

  

 Thanks

  

  

 Yair Ben-Meir

  

 Office: 073-7997801

 Fax: 073-7997800

 Mob:   054-5769681



  


 
 
 -
 To start a new topic, e-mail: users@tomcat.apache.org
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 
 
 -
 To start a new topic, e-mail: users@tomcat.apache.org
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: multithreaded with taglibs

2007-11-25 Thread Yair Ben-Meir
Thanks, but that's not good for me, I need the page to be with a real file
link (file://), not through a servlet.


-Original Message-
From: Pid [mailto:[EMAIL PROTECTED] 
Sent: Sunday, November 25, 2007 11:53 AM
To: Tomcat Users List
Subject: Re: multithreaded with taglibs

Yair Ben-Meir wrote:
 Let say that the tag will have to generate the image with a text given as
an
 attribute, and it takes time so I want the page to continue:
 
 my:img src=file text=first/
 
 .
 
 my:img src=file text=first/

Why are you doing this with a tag, rather than sending the parameter to
a servlet that serves an image into it's output stream?

You exploit the browsers own request handling capabilities this way.

img src=/img-app/generate?param1=some+text+here alt=an image /


p



 -Original Message-
 From: David Cassidy [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, November 22, 2007 6:08 PM
 To: Tomcat Users List
 Subject: Re: multithreaded with taglibs
 
 Hi
 
 What is your tag going to produce ?
 is it an IMG SRC=. type tag ?
 
 or how are you allowing the browser to access the image ?
 
 Ta
 
 D
 
 On Thu, 2007-11-22 at 14:57 +0200, Yair Ben-Meir wrote:
 Hi

 Is there a way to write a taglib that will do a multithreading work?
 Meaning, that tomcatwill not wait till the first instance of the tag
 will end, and continue to the rest of the page, and maybe start with
 another instance, and than it will insert the result of each instance
 in the right place?

  

 Example:

 my:img name=/

 .

 my:img name=/

  

 And let say that each my:img is supposed to download the image and
 save it locally or something like that, and I don't want tomcat to
 wait till the first tag is finished.

  

  

 Thanks

  

  

 Yair Ben-Meir

  

 Office: 073-7997801

 Fax: 073-7997800

 Mob:   054-5769681



  


 
 
 -
 To start a new topic, e-mail: users@tomcat.apache.org
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 
 
 -
 To start a new topic, e-mail: users@tomcat.apache.org
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: multithreaded with taglibs

2007-11-24 Thread Yair Ben-Meir
Let say that the tag will have to generate the image with a text given as an
attribute, and it takes time so I want the page to continue:

my:img src=file text=first/

.

my:img src=file text=first/


-Original Message-
From: David Cassidy [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 22, 2007 6:08 PM
To: Tomcat Users List
Subject: Re: multithreaded with taglibs

Hi

What is your tag going to produce ?
is it an IMG SRC=. type tag ?

or how are you allowing the browser to access the image ?

Ta

D

On Thu, 2007-11-22 at 14:57 +0200, Yair Ben-Meir wrote:
 Hi
 
 Is there a way to write a taglib that will do a multithreading work?
 Meaning, that tomcatwill not wait till the first instance of the tag
 will end, and continue to the rest of the page, and maybe start with
 another instance, and than it will insert the result of each instance
 in the right place?
 
  
 
 Example:
 
 my:img name=/
 
 .
 
 my:img name=/
 
  
 
 And let say that each my:img is supposed to download the image and
 save it locally or something like that, and I don't want tomcat to
 wait till the first tag is finished.
 
  
 
  
 
 Thanks
 
  
 
  
 
 Yair Ben-Meir
 
  
 
 Office: 073-7997801
 
 Fax: 073-7997800
 
 Mob:   054-5769681
 
 
 
  
 
 


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: multithreaded with taglibs

2007-11-22 Thread David Cassidy
Hi

What is your tag going to produce ?
is it an IMG SRC=. type tag ?

or how are you allowing the browser to access the image ?

Ta

D

On Thu, 2007-11-22 at 14:57 +0200, Yair Ben-Meir wrote:
 Hi
 
 Is there a way to write a taglib that will do a multithreading work?
 Meaning, that tomcatwill not wait till the first instance of the tag
 will end, and continue to the rest of the page, and maybe start with
 another instance, and than it will insert the result of each instance
 in the right place?
 
  
 
 Example:
 
 my:img name=””/
 
 …
 
 my:img name=””/
 
  
 
 And let say that each my:img is supposed to download the image and
 save it locally or something like that, and I don’t want tomcat to
 wait till the first tag is finished.
 
  
 
  
 
 Thanks
 
  
 
  
 
 Yair Ben-Meir
 
  
 
 Office: 073-7997801
 
 Fax: 073-7997800
 
 Mob:   054-5769681
 
 
 
  
 
 


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]