1

I am implementing a simple website to test quering SQL statements and displaying the results in PHP.

Here's the structure:

  1. PHP code to display the table and results (Front-end)
  2. Java SQL to do the processing. A simple java function to query SQL statements and direct the results onto the PHP code. (Back-end)

The question is, how do I link the PHP code with the Java back-end? Is there a framework that I'll need to use to connect those two? Or is it a simple code?

I will be using MySQL via Xampp.

Any ideas/help would be appreciated it.

Jeiman
  • 1,121
  • 9
  • 27
  • 50
  • If you're using Java for the backend, then just use Facelets or JSP for the view. Do not use PHP. – Sully Jan 27 '14 at 07:03
  • Why not use PHP? Isn't it simpler to call out the SQL statements? What are the pros and cons of using JSP versus PHP if I may ask? – Jeiman Jan 27 '14 at 07:44

2 Answers2

1

First, you need to decide on which server/back-end technology you will use. It's either Java or PHP.

If you decide to use Java then you do not need PHP and vice versa.

Deciding which tools to use is important and that will depend on what you are trying to develop.

If you use Java as your server side you will get the data using JDBC connection and creating the result set in Java. Then using the request you populate a JSP page using tags like JSTL.

So for Java, choose a framework: Options are JSF, Struts, Spring and a couple more. Or just use JSP technology.

For PHP, like I mentioned above, you won't need Java. If you're using Java because of some libraries then just stick to Java.. You won't need PHP.

Edit:

JSF is a componenet based framework that has the option to use Facelets for the view, which allows the use of HTML instead of having to write JSPs.

JSPs are basically HTML with Java code.

So you will have to decide JSP or Facelets and not both. JSP is a bit older.

JSF 2.0 with Facelets is a very good option to start learning Java Web development.

So for the differences, there are many posts here that compare all of the frameworks in more than one question and here are some:

What is the difference between JSF, Servlet and JSP?

JSF vs Facelets vs JSP

Spring MVC vs JSF

And there are more.. Start with JSF 2.0 and Facelets and here is a netbeans tutorial http://netbeans.org/kb/docs/web/jsf20-intro.html

Community
  • 1
  • 1
Sully
  • 14,672
  • 5
  • 54
  • 79
  • I see. I also noticed PHP by looking at some sample code that it has its own functions to retrieve and query SQL statements. I might try out doing the web application using JSF or Facelets. My next question would be what is the difference between Facelets and JSF. If im not mistaken, I think JSF is a MVC framework, but unsure of Facelets and how it works. I'm using the latest version of Netbeans which has Facelets capabilities, but im not sure whether it incorporates the JSF functionality, if you know what I mean. – Jeiman Jan 27 '14 at 08:13
  • Thanks alot buddy. That's really going to help me understand the architecture better. :) – Jeiman Jan 27 '14 at 08:55
0

I wouldn't necessarily use Java as a backend, but the easiest way I can think to do that would be to connect them up internally over a socket.

For PHP: http://www.php.net/manual/en/book.sockets.php For Java: http://docs.oracle.com/javase/tutorial/networking/sockets/

jnesselr
  • 941
  • 1
  • 7
  • 12