RE: API for running JSP
Well, I found a solution: String path = C:\\Program Files\\tomcat6; Embedded embedded = new Embedded(); embedded.setCatalinaBase(path); embedded.setCatalinaHome(C:\\Program Files\\tomcat6); Engine engine = embedded.createEngine(); engine.setDefaultHost(localhost); engine.setName(myCatalina); Host host = embedded.createHost(localhost, webapps); engine.addChild(host); // Root context. Context context = embedded.createContext(, path + \\webapps\\ROOT); host.addChild(context); // mywebapp context. context = embedded.createContext(/mywebapp, path + \\webapps\\mywebapp); host.addChild(context); embedded.addEngine(engine); Connector connector = new Connector(); embedded.start(); StandardWrapper jsp = (StandardWrapper) context.findChild(jsp); JspServlet serv = (JspServlet) jsp.getServlet(); Request request = new Request(); Response response = new Response(); org.apache.coyote.Request coyoteRequest = new org.apache.coyote.Request(); request.setContextPath(/mywebapp); request.setServletPath(/try1.jsp); request.setCoyoteRequest(coyoteRequest); request.setContext(context); request.setConnector(connector); request.setResponse(response); response.setConnector(connector); response.createOutputStream(); org.apache.coyote.Response coyoteResponse = new org.apache.coyote.Response(); InternalOutputBuffer iob = new InternalOutputBuffer(coyoteResponse); ByteArrayOutputStream result = new ByteArrayOutputStream(); iob.setOutputStream(result); coyoteResponse.setOutputBuffer(iob); response.setRequest(request); response.setCoyoteResponse(coyoteResponse); serv.service(request, response); response.finishResponse(); if (response.isError()) { throw new Exception(Status: +response.getStatus() + , message: + response.getMessage()); } System.out.println(result.toString()); embedded.stop(); The question now is, can I give the JspServlet a foreign jsp file (a path outside of the context) to run? Thanks, Yair - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
API for running JSP
Hi I m looking for a way to run a JSP by an API from my code, instead of sending an HTTP request to a server. That means that I m not going to start tomcat, and instead just use Tomcat's classes to run a JSP from my (desktop) application, as if surfing to it. Is there way to do this? Thanks Yair
RE: multithreaded with taglibs
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
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
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
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
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
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
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]
multithreaded with taglibs
Hi Is there a way to write a taglib that will do a multithreading work? Meaning, that tomcat will 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 image001.jpg
cluster deployer (farming)
Hi If I understand correctly, the cluster deployer is currently broken (I've tried running it with two tomcat instances on my machine in a cluster, and it threw me some exceptions). Is it going to be fixed? And if so, when? Thanks Yair Ben-Meir Office: 073-7997801 Fax: 073-7997800 Mob: 054-5769681 image001.jpg