Foro de elhacker.net

Programación => PHP => Mensaje iniciado por: klaine en 2 Diciembre 2011, 21:19 pm



Título: [PHP + JSP] Es posible?
Publicado por: klaine en 2 Diciembre 2011, 21:19 pm
Hola, estuve leyendo en un libro que se podía mezclar java con php, en el servidor tomcat, dejo el extracto del libro:

Introduccion:

Cita de: (2004) Php 5 And Mysql Bible

The relationship between PHP and Java has changed significantly
with each new release. Unsurprisingly, given the source code, PHP
initially had much more in common with C. PHP4 supported integration
of PHP and Java using a Java Servlet environment or, more experimentally,
directly into PHP. Finally, with the overhaul of the object
model in PHP5, there’s a distinctly Java feel to the PHP approach to
object oriented programming. Java users will find much of PHP5’s
new object model very familiar, though with important differences.
Given these changes, as PHP takes on a more Java-like cast, there are
two possibilities for which a discussion of PHP and Java might be
pertinent. You might need to work on a project that requires PHP and
Java or Java Server Pages (JSP) to work in tandem. Or you may be
approaching PHP from a Java background and want to know about
the similarities and differences in order to learn PHP faster. We will
deal with both needs in this chapter.
If you don’t have a need to use Java, or aren’t already


Expolicacion y ejemplo:

Cita de: (2004) Php 5 And Mysql Bible

Java Server Pages and PHP
PHP can fulfill many functions similarly to Java Server Pages (JSP). The JSP servlet engine
serves as a scripting language for use with Java, and, just as PHP, is often used in front end
applications.
Embedded HTML
PHP is more similar to JSP than Java itself in that you are allowed to write HTML directly
rather than using endless print statements. Unlike Java, but like JSP, variables can also be
referenced from within a block of HTML. A simple HTML page using JSP script might look
like this:
<%
String greeting = “Hello, world”;
%>
<HTML>
<HEAD>
<TITLE>Fun with JSP</TITLE>
</HEAD>
<BODY>
<H1><%= greeting %></H1>
</BODY>
</HTML>
Similarly, using PHP, you can write:
<?php
$greeting = “Hello, World”;
?>
<HTML>
<HEAD>
<TITLE>Fun with PHP</TITLE>
722 Part IV ✦ Connections
</HEAD>
<BODY>
<H1><?php echo $greeting ?></H1>
</BODY>
</HTML>
Pages can freely alternate between HTML and JSP, just as in using HTML and PHP.


De antemano, gracias por sus respuestas.

PD: Tengo el apache tomcat instalado, pero es la instalacion que viene por defecto, sinceramente no se por donde empezar, si alguien quiere el libro que me mande un mp y se lo mando por correo. 1083 paginas, esto de java+php empieza en la 719


Título: Re: [PHP + JSP] Es posible?
Publicado por: #!drvy en 15 Diciembre 2011, 04:48 am
Si, es posible.

Código:
http://apacheguide.org/

Aquí te dan todo lo necesario.


Saludos