Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Pros and Cons .jsp vs .php

 
Ranch Hand
Posts: 234
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are the pros and cons of Sun's .JSP vs PHP?
I know PHP works well with mySQL, others commented that since I am writing mainly in Java anf FX, .JSP is a good fit...
 
Ranch Hand
Posts: 128
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can have a look at the following PHP vs JSP comparison
 
Saloon Keeper
Posts: 6448
158
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I know PHP works well with mySQL


As does JSP. In fact, both work well with just about DB you care to use. Of course, you wouldn't access the DB from within JSP directly in a properly designed app, whereas with PHP, you have to. So that's one difference: for a quick and dirty app, or one that's not too complicated, PHP is OK. For something enterprise-grade, Java is likely better choice.
 
Saloon Keeper
Posts: 22122
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's my top reasons.

PHP pro:

* Rapid prototyping and deployment. Just code a page and it's ready to go. No need to set up an elaborate project or install a special server (Apache+PHP is pretty standard in Linux).

PHP con:

* OOP is a foreign concept to PHP. Makes maintenance of large projects difficult
* Separation of Concerns is also a foreign concept. While JSP can be coded with the entire app on a single page, that's heavily discouraged in favor of using JSPs as the View part of a Model/View/Controller setup, where a servlet server as the Controller.
* PHP is weak on standardization. The APIs for different brands of databases are completely different in core PHP - although frameworks have since been developed to reduce that. Contrast that with JDBC. Or JPA.
* PHP in its basic form is interpreted, with performance issues that go with it. I don't worry about this one as much, however, since performance boosters for PHP go way back.
* PHP is infamous for security problems. Java was designed for security from the original VM up, and JEE has a very tight standard security framework.

Systems like Laravel reduce a lot of the aforementioned PHP problems, but then you end up with the same sort of complexities that you see when setting up a JEE project.

Don't think that I hate PHP, though. Until recently, whenever I wanted a quick-and-dirty webapp, I'd code it in PHP - although NodeJS seems to work better for me these days. And of course, some of my favorite webapps are PHP, including the venerable Wikipedia and Wordpress.
 
AhFai Chan
Ranch Hand
Posts: 234
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, in MVC architecture, I can understand JSP is the "View" taking over the role of an applet, and backend logic as "Controllers" taking over over from servlets accessing the db.
The thinng is, I have an FX GUI with business logic in controllers and I need to access a DB server. In order to upload or download to the DB server, I am using PHP and JSON. That's how PHP became part of my software ecosystem.
Are you saying I can bypass the PHP and JSON by using JSP??
 
Sheriff
Posts: 67403
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, as you already pointed out, JSPs are view technology; no processing should take place in JSPs. Rather, servlets should coordinate access to other resources written in Java classes. DB handling, for example, would happen in the Model layer.

Please read this article for information on structuring Java web applications.

You might also investigate the Spring ecosystem.
 
AhFai Chan
Ranch Hand
Posts: 234
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:No, as you already pointed out, JSPs are view technology; no processing should take place in JSPs. Rather, servlets should coordinate access to other resources written in Java classes. DB handling, for example, would happen in the Model layer.

Please read this article for information on structuring Java web applications.

You might also investigate the Spring ecosystem.



Thank-you, will read :)

Am using Model for data from db. My major problem is the db-data in FX getter-setter are not accessible from other scenes and windows, but I am using .properties, don't know whether that's a security issue.

 
AhFai Chan
Ranch Hand
Posts: 234
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:No, as you already pointed out, JSPs are view technology; no processing should take place in JSPs. Rather, servlets should coordinate access to other resources written in Java classes. DB handling, for example, would happen in the Model layer.

Please read this article for information on structuring Java web applications.

You might also investigate the Spring ecosystem.



This reminds me of Tomcat.
 
Today you are you, that is turer than true. There is no one alive who is youer than you! - Seuss. Tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic