Solved

PHP  <>  J2ee

Posted on 2007-04-10
3
450 Views
Last Modified: 2010-08-05
Hi,

I am using JSP when developing web applications, and learning PHP.
In my j2ee based web applications, I have usually an "application configuration" ,
which is an xml file that defines some constants for my web applications.
I have then a start-on-load servlet, which is a thread that is running when the web application starts,
and is reading this xml file and put the constant in memory (static variables).

I wonder how we can do such things in PHP ... since I can't see anything about threads.

Another example would be a user making a request that takes a very long time for the application,
in JSP i would launch a new thread, so that user don't have to wait this long process,
but in PHP this isn't possible.

A last example :
I have a chat server and I want to display on my website the status of this chat server
(on / off / number of connected / etc.)
In JSP it is quite simple, I could launch a thread, which is querying every X seconds the chat server,
and change some constants in the web application. In my .jsp pages, for each user request (user thread) I just read the constants and display them.
How could I do such a thing in PHP ?

Thak u for any comment.
0
Comment
Question by:matthew016
  • 2
3 Comments
 
LVL 49

Accepted Solution

by:
Roonaan earned 500 total points
ID: 18880984
Each php call is processed on its own. There is no shared memory. you can just define your constants in a config.php file which is called on each script execution.

You might be interested in viewing php/java as two parts working together rather than competitive technologies. Using java from php and php from java and using the best from both technologies.

There should be no reason to not keep your chat server status monitor as java, while running the rest of your website on php.
0
 
LVL 9

Author Comment

by:matthew016
ID: 18881028
Thank u Roonaan for clarifying.

Ok I see, in a j2ee environment the threads are running in the Java Virtual Machine (JVM) of the web application, which means that each thread has access to the other classes instantiated within this JVM.

In PHP, each user request is also a thread ? Or how is this called in the PHP world ? How are each user request processed ?

How could I combine the two technologies,
for example for this chat monitor, if I write it in a servlet or a standard Java class,
I have no idea on how to interact   PHP - Java   technology.
0
 
LVL 49

Expert Comment

by:Roonaan
ID: 18881044
Using php5 you can communicate (from code) with java depending on your setup. I have not worked with application servers capable of doing so (yet), so I am not familiar with the subject. I am in the process of gathering information on the subject, but haven't got a structured view at this stage.

This article might be interesting for you as well: http://dev2dev.bea.com/pub/a/2007/02/php-java-bridge.html

-r-
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now