Solved

PHP  <>  J2ee

Posted on 2007-04-10
3
446 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

760 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

20 Experts available now in Live!

Get 1:1 Help Now