Jump to content
xisto Community
masrawy

Jsp Versus Php about differences between JSP and PHP

Recommended Posts

Both of JSP and PHP are technologies used to build dynamic web sites, JSP embeds java syntax with html to create dynamic pages, while PHP is an open-source page scripting/templating system, but in the long run, JSP and Java provide a more powerful system.

Here is a list of reasons why JSP is better than PHP:

- Anything you can do with PHP, you can do with JSP; the reverse is not true
- JSP is much more powerful, since it has access to all the Java libraries. PHP only has access to PHP libraries

- JSP is Object-Oriented, so leads to cleaner code that's easier to debug, maintain, and improve. (PHP also allows objects, but the - object model is more primitive, and most scripted pages ignore PHP objects and just use normal variables.)

- The equivalent syntax in JSP is just as simple to learn, so you can get up and running just as quickly -- that is, there's no extra startup cost in using Java, at least not a significant one

- Java programmers (as opposed to 15-year-old hackers or HTML monkeys) appreciate the importance of a clean language with complex OO data structures and strong typing

- With JSP, if the code inside a page gets too big, or if you want to use it elsewhere, you can cut it out, make it into a Java class, and invoke it from anywhere in your application (even not from a page). With PHP, you're stuck inside the HTML box.

- JSP's concept of state management and persistence is more explicit and powerful than PHP's. With JSP, you can specify whether a variable persists for the page, the request, the session, or the application (or if it's just local to the function). The JSP engine automatically does the right thing with cookies so you have access to the variable on later requests. With PHP, you just have "global" and "not global", you don't have automatic session management, and have to do your state thing manually with cookies or hidden variables.


any comments will be apppreciated.

Notice from rvalkass:

Anything you copy should be put in Quote tags.
Readme ~ Rules ~ AUP

Share this post


Link to post
Share on other sites

- Anything you can do with PHP, you can do with JSP; the reverse is not true

Care to elaborate? Anything I can do in JSP I can also do in C, which I can also do in assembler. I can also do things in C which I can not do in Java (direct memory access, for example). Therefore using that logic all websites should be written in C.

- JSP is much more powerful, since it has access to all the Java libraries. PHP only has access to PHP libraries

C has access to all of the PHP and Java libraries (using the appropriate bridges). C wins again.

- JSP is Object-Oriented, so leads to cleaner code that's easier to debug, maintain, and improve. (PHP also allows objects, but the - object model is more primitive, and most scripted pages ignore PHP objects and just use normal variables.)

PHP5 supports almost exactly the same object model as Java. Abstract classes, interfaces, public, protected and private member variables/functions, pass by reference, static functions/variables.
Your second point (about developers ignoring such features) notwithstanding; the features of a language exploited by its respective community is irrelevant when comparing languages. The fact of the matter is they exit.

By inflection you are also categorically static that object orientated code is always better. I dispute that. If Java was multi paradigm (like PHP or C++) I wonder how many people would forgo the object orientated features in some situations.

- The equivalent syntax in JSP is just as simple to learn, so you can get up and running just as quickly -- that is, there's no extra startup cost in using Java, at least not a significant one

The number of hosts supporting JSP is smaller than that of PHP. The PHP community is significantly larger (for the hobbiest sector anyway). I know both Java (I normally use Swing/SWT, so desktop apps) and can tell you it is a lot harder than PHP.
Try explaining to a beginner how to connect to a MySQL/PostgresSQL database in Java using JDBC and then compare it to the required PDO code.

- Java programmers (as opposed to 15-year-old hackers or HTML monkeys) appreciate the importance of a clean language with complex OO data structures and strong typing

Again, this is not a language thing, but more a social one. Notwithstanding.

- With JSP, if the code inside a page gets too big, or if you want to use it elsewhere, you can cut it out, make it into a Java class, and invoke it from anywhere in your application (even not from a page). With PHP, you're stuck inside the HTML box.

100% not true. On the lowest level PHP supports including of other PHP files. Boom, a simple template system. Further up the food chain there is Smarty (a true templating language) and even further up there is ezcComponents and the Zend Framework, which provide the MVC design pattern to PHP.

- JSP's concept of state management and persistence is more explicit and powerful than PHP's. With JSP, you can specify whether a variable persists for the page, the request, the session, or the application (or if it's just local to the function). The JSP engine automatically does the right thing with cookies so you have access to the variable on later requests. With PHP, you just have "global" and "not global", you don't have automatic session management, and have to do your state thing manually with cookies or hidden variables.

PHP has sessions http://forums.xisto.com/no_longer_exists/ . They are 100% transparent to both the programmer and user.
Regards, Freddie.
Edited by evilguru (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.