Solved

PHP  <>  J2ee

Posted on 2007-04-10
3
456 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

688 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