From: <php...@li...> - 2010-09-06 02:05:45
|
Hi, I need to access a servlet (not created by me) from a PHP script using file_get_contents, but I need to maintain the same session which at the moment isn't happening. Does anyone have any idea of how (if possible) I can achieve this? I have access to the session and servlet request information in the PHP script, I just need to find a way to send it to the servlet. Thanks, Sincerely, Marta Fernandes |
From: <php...@li...> - 2010-09-06 16:32:39
|
Hi, > I need to access a servlet (not created by me) from a PHP script using > file_get_contents, but I need to maintain the same session Don't. Please use requestDispatcher.include() instead. You cannot re-connect to the current HTTP server. If you do, you might run into a deadlock. Imagine a HTTP server with a pool size of 1. If you invoke a script t1.php and open a URLConnection back to http://localhost/t2.php, you HTTP server will block until t1 terminates, which will never happen because it waits for the HTTP server to deliver the content of t2. Please either use the java_virtual() method or (if running in apache or iis) the virtual() method, which bypass the HTTP servers thread-/process pool. This will solve your session problem, too. :) Regards, Jost Bökemeier |
From: <php...@li...> - 2010-09-10 02:17:21
|
Hi, I did some research on requestDispatcher.include() and java_virtual() and I see why you recommended their use. However, I'm using the file_get_contents() method in order to post some data to the servlet (using the stream_context_create() method). I don't suppose I can do that with either requestDispatcher.include() or java_virtual(). Or can I? Sincerely, Marta Fernandes > Date: Mon, 6 Sep 2010 18:32:33 +0200 > To: php...@li... > From: php...@li... > Subject: Re: [Php-java-bridge-users] Sending request object to servlet with file_get_contents > > Hi, > > > I need to access a servlet (not created by me) from a PHP script using > > file_get_contents, but I need to maintain the same session > > Don't. Please use requestDispatcher.include() instead. > > You cannot re-connect to the current HTTP server. If you do, you might > run into a deadlock. > > Imagine a HTTP server with a pool size of 1. If you invoke a script > t1.php and open a URLConnection back to http://localhost/t2.php, you > HTTP server will block until t1 terminates, which will never happen > because it waits for the HTTP server to deliver the content of t2. > > Please either use the java_virtual() method or (if running in apache > or iis) the virtual() method, which bypass the HTTP servers > thread-/process pool. > > This will solve your session problem, too. :) > > > Regards, > Jost Bökemeier > > ------------------------------------------------------------------------------ > This SF.net Dev2Dev email is sponsored by: > > Show off your parallel programming skills. > Enter the Intel(R) Threading Challenge 2010. > http://p.sf.net/sfu/intel-thread-sfd > _______________________________________________ > php-java-bridge-users mailing list > php...@li... > https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users |
From: <php...@li...> - 2010-09-11 11:14:30
|
Hi, I don't understand. Do you have a use case? Regards, Jost Bökemeier |
From: <php...@li...> - 2010-09-11 19:21:15
|
Hi, I don't have a use case because what I'm trying to do is a very small thing. Lets see if I can explain a little better. I'm working with "AHA!" which is an open source adaptive hypermedia architecture. The AHA was developed using Java but I'm working with PHP. This of course is forcing me to work with both languages together. At the moment what I have to do involves accessing and updating an XML file created by the AHA, which isn't at all a hard thing to do. However, the AHA already has a servlet that does that and one of the Professors I'm working with asked me to try and use that servlet to update the file instead of doing it myself. The servlet receives information from a form (via POST) and updates the XML file accordingly. So basicaly I need to be able to pass information to that specific servlet and I have to do that using PHP. I was trying to do that using file_get_contents() because this method allows me to use a context with which I can send the necessary information. Does any of this make sense to you? Sincerely, Marta Fernandes > Date: Sat, 11 Sep 2010 13:14:23 +0200 > To: php...@li... > From: php...@li... > Subject: Re: [Php-java-bridge-users] Sending request object to servlet with file_get_contents > > Hi, > > I don't understand. Do you have a use case? > > > Regards, > Jost Bökemeier > > ------------------------------------------------------------------------------ > Start uncovering the many advantages of virtual appliances > and start using them to simplify application deployment and > accelerate your shift to cloud computing > http://p.sf.net/sfu/novell-sfdev2dev > _______________________________________________ > php-java-bridge-users mailing list > php...@li... > https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users |
From: <php...@li...> - 2010-09-11 19:58:08
|
is this your only requirement for using the bridge? have you considered http://de.php.net/manual/en/class.httprequest.php or http://de.php.net/curl instead? On Sat, Sep 11, 2010 at 9:21 PM, <php...@li...> wrote: > > Hi, > > I don't have a use case because what I'm trying to do is a very small thing. Lets see if I can explain a little better. > I'm working with "AHA!" which is an open source adaptive hypermedia architecture. The AHA was developed using Java but I'm working with PHP. This of course is forcing me to work with both languages together. > At the moment what I have to do involves accessing and updating an XML file created by the AHA, which isn't at all a hard thing to do. However, the AHA already has a servlet that does that and one of the Professors I'm working with asked me to try and use that servlet to update the file instead of doing it myself. The servlet receives information from a form (via POST) and updates the XML file accordingly. So basicaly I need to be able to pass information to that specific servlet and I have to do that using PHP. I was trying to do that using file_get_contents() because this method allows me to use a context with which I can send the necessary information. > Does any of this make sense to you? > > Sincerely, > > Marta Fernandes > >> Date: Sat, 11 Sep 2010 13:14:23 +0200 >> To: php...@li... >> From: php...@li... >> Subject: Re: [Php-java-bridge-users] Sending request object to servlet with file_get_contents >> >> Hi, >> >> I don't understand. Do you have a use case? >> >> >> Regards, >> Jost Bökemeier >> >> ------------------------------------------------------------------------------ >> Start uncovering the many advantages of virtual appliances >> and start using them to simplify application deployment and >> accelerate your shift to cloud computing >> http://p.sf.net/sfu/novell-sfdev2dev >> _______________________________________________ >> php-java-bridge-users mailing list >> php...@li... >> https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users > > ------------------------------------------------------------------------------ > Start uncovering the many advantages of virtual appliances > and start using them to simplify application deployment and > accelerate your shift to cloud computing > http://p.sf.net/sfu/novell-sfdev2dev > _______________________________________________ > php-java-bridge-users mailing list > php...@li... > https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users > -- Dominik Dorn http://dominikdorn.com http://twitter.com/domdorn Tausche Deine Lernunterlagen auf http://www.studyguru.eu ! |
From: <php...@li...> - 2010-09-12 10:41:31
|
Hi Marta, first of all, requestDispatcher.forward() lets you forward POST requests. But I don't think this works with include(). Second: some application servers like Sun Java AS 9 have a very small thread pool size. If you open a loop-back connection to the back end, you risk to lock up the whole application server. AS 9 pool size defaults to 5, which means that 3 concurrent user requests *will* lock up your application server forever, if your servlet opens a HTTP URL connection back to your application server. Apache's pool is larger, it defaults to MaxChilds=150. Send it more than 75 concurrent requests and it will stop responding forever. So file_get_contents(localURL) or a loopback java.net.URLConnection to the back end is not an option. Forget that. If your JSP has been written properly, it separates the business- from the UI logic. So it should be easy to call the business methods from your PHP servlet as well. If not, your only option is to refactor the JSP or to duplicate some of its functionality. A third option (but rather lo-tech) is to ask the browser to deliver the content of your JSP and to deliver it to your PHP servlet using AJAX. Regards, |