473,326 Members | 2,110 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

is it possible to combine jsp and php?

here's my problem - i run a web site with a java servlet backend
(apache/tomcat/linux/mysql), and i want to add some php content to my jsp
pages. why would i want to do something like this? i want to add some
third party blogging software that's written in php. it would be easy to
have two entirely different sets of pages - but i don't want a MacDLT
solution. i'd like to be able to have blog content throughout the website.

is there some standard way of doing this?

daniel
Jul 17 '05 #1
7 16943
Blah Blah wrote:
here's my problem - i run a web site with a java servlet backend
(apache/tomcat/linux/mysql), and i want to add some php content to my jsp
pages. why would i want to do something like this? i want to add some
third party blogging software that's written in php. it would be easy to
have two entirely different sets of pages - but i don't want a MacDLT
solution. i'd like to be able to have blog content throughout the website.

is there some standard way of doing this?

daniel


Apache 2.0 allows pipelining of module processing. unfortunately, I know
nothing about if there is a module (for apache2) which will run a JSP
processor.

I would be more inclined to use a [virtual?] "remote" method. So from
the PHP script, you can do something like
$fileResource = fopen("http://localhost/tomcat/fooapp/foo.jsp","r");
In this case, your JSP is processed first and the interpreted output is
accessible from PHP.

You can go the other way and do a remote include (doing whatever it is
you need to do in jsp) to access the PHP script via HTTP instead of the
local filesystem.
Jul 17 '05 #2
Terence wrote:
Blah Blah wrote:
here's my problem - i run a web site with a java servlet backend
(apache/tomcat/linux/mysql), and i want to add some php content to my jsp
pages. why would i want to do something like this? i want to add some
third party blogging software that's written in php. it would be easy to
have two entirely different sets of pages - but i don't want a MacDLT
solution. i'd like to be able to have blog content throughout the
website.

is there some standard way of doing this?

daniel
Apache 2.0 allows pipelining of module processing. unfortunately, I know
nothing about if there is a module (for apache2) which will run a JSP
processor.

I would be more inclined to use a [virtual?] "remote" method. So from
the PHP script, you can do something like
$fileResource = fopen("http://localhost/tomcat/fooapp/foo.jsp","r");
In this case, your JSP is processed first and the interpreted output is
accessible from PHP.


I think you can simply

include "http://localhost/tomcat/fooapp/foo.jsp";

(never tried it)

You can go the other way and do a remote include (doing whatever it is
you need to do in jsp) to access the PHP script via HTTP instead of the
local filesystem.


Jul 17 '05 #3
"Blah Blah" <bl**@blahblah.com> wrote in message
news:<P5********************@comcast.com>...

here's my problem - i run a web site with a java servlet backend
(apache/tomcat/linux/mysql), and i want to add some php content to my jsp
pages. why would i want to do something like this? i want to add some
third party blogging software that's written in php. it would be easy to
have two entirely different sets of pages - but i don't want a MacDLT
solution. i'd like to be able to have blog content throughout the website.


You have a number of options here...

First of all, note that you, by your own admission, want "to have blog
content throughout the website". Content, not layout. So you can write
some JSP code to read content of the blog directly from the database
that holds it and leave the PHP application in place only for writing
entries/comments.

Option number two: deploy the PHP-based blog in a separate frame.

Option number three: insert PHP-generated content into your JSP pages
as if it were static content. In other words, you need a JSP analog
of

readfile ('http://yoursite.com/yourpath/yourscript.php');

This one is likely to be somewhat slow though... There may be issues
with hyperlinks/references, too...

Option number four: wait until PHP integrates with Java natively
(which is in works right now) and stop using JSP altogether.

Cheers,
NC
Jul 17 '05 #4
sir, you are a gentleman and a scholar.
using "include" appears to make everything work.
although it introduces an interesting wrinkle - it appears that the way to
organize things this way is to make one php file per jsp file, to include
the jsp files in their respective php files, and then have all of the links
(in the jsp files) point to php files. somewhat circular, but interesting.

you have just saved me a TON of work (where do i send the beer? ;)

another bonus: by processing the jsp files first, tomcat is able to compile
them to bytecode once instead of interpreting them from scratch each time
(if a file changes, tomcat has to recompile them). which raises the php
newbie question: does php do the same thing, and compile php files to
bytecode the first time they're read? or does it interpret them each time?

daniel

"Terence" <tk******@fastmail.fm> wrote in message news:3fbab50f$1@herald...
Terence wrote:
Blah Blah wrote:
here's my problem - i run a web site with a java servlet backend
(apache/tomcat/linux/mysql), and i want to add some php content to my jsp pages. why would i want to do something like this? i want to add some
third party blogging software that's written in php. it would be easy to have two entirely different sets of pages - but i don't want a MacDLT
solution. i'd like to be able to have blog content throughout the
website.

is there some standard way of doing this?

daniel


Apache 2.0 allows pipelining of module processing. unfortunately, I know
nothing about if there is a module (for apache2) which will run a JSP
processor.

I would be more inclined to use a [virtual?] "remote" method. So from
the PHP script, you can do something like
$fileResource = fopen("http://localhost/tomcat/fooapp/foo.jsp","r");
In this case, your JSP is processed first and the interpreted output is
accessible from PHP.


I think you can simply

include "http://localhost/tomcat/fooapp/foo.jsp";

(never tried it)

You can go the other way and do a remote include (doing whatever it is
you need to do in jsp) to access the PHP script via HTTP instead of the
local filesystem.

Jul 17 '05 #5
Blah Blah wrote:
sir, you are a gentleman and a scholar.
using "include" appears to make everything work.
although it introduces an interesting wrinkle - it appears that the way to
organize things this way is to make one php file per jsp file, to include
the jsp files in their respective php files, and then have all of the links
(in the jsp files) point to php files. somewhat circular, but interesting.

you have just saved me a TON of work (where do i send the beer? ;)

another bonus: by processing the jsp files first, tomcat is able to compile
them to bytecode once instead of interpreting them from scratch each time
(if a file changes, tomcat has to recompile them). which raises the php
newbie question: does php do the same thing, and compile php files to
bytecode the first time they're read? or does it interpret them each time?

The short answer is no.

the real answer is, yes, only if you employ a pre-compiler. There are a
range of pre-compilers avialble which use resultant binaries (none of
this pussy pseudo-code crap ;)) after the first access (which compiles
on demand). Many people get away with just using the interpreter as-is
in high-performance environments.

You will find that PHP gives you a lot of choice in many many ways.
This is one of the reasons why it is so popular even without marketing.
I'm glad include "http://..." is working for you, it relies on a
directive in the php.ini file to allow remote access in local file
functions. Obviously this is on by default :)

daniel

"Terence" <tk******@fastmail.fm> wrote in message news:3fbab50f$1@herald...
Terence wrote:

Blah Blah wrote:
here's my problem - i run a web site with a java servlet backend
(apache/tomcat/linux/mysql), and i want to add some php content to my
jsp
pages. why would i want to do something like this? i want to add some
third party blogging software that's written in php. it would be easy
to
have two entirely different sets of pages - but i don't want a MacDLT
solution. i'd like to be able to have blog content throughout the
website.

is there some standard way of doing this?

daniel

Apache 2.0 allows pipelining of module processing. unfortunately, I know
nothing about if there is a module (for apache2) which will run a JSP
processor.

I would be more inclined to use a [virtual?] "remote" method. So from
the PHP script, you can do something like
$fileResource = fopen("http://localhost/tomcat/fooapp/foo.jsp","r");
In this case, your JSP is processed first and the interpreted output is
accessible from PHP.


I think you can simply

include "http://localhost/tomcat/fooapp/foo.jsp";

(never tried it)

You can go the other way and do a remote include (doing whatever it is
you need to do in jsp) to access the PHP script via HTTP instead of the
local filesystem.



Jul 17 '05 #6
looks like i broke out the champagne a little too early.
there's one key problem: submitting a form won't go to the servlet. so,
given the following html:

<FORM name="logonForm" action="/myApp/LogonSubmit.do" method="post">
User Name:<INPUT type="text" name="userName" /><br />
Password:<INPUT type="password" name="password" /><br />
<INPUT type="submit" value="Submit" />
</FORM>

it wants to go to http://localhost/myApp/LogonSubmit.do, not
http://localhost:8080/myApp/LogonSubmit.do.
is there any way around this?

if we can figure out a solution, this would allow me to mix and match php
and jsp in one file. otherwise, i'm going to have to go with a somewhat more
painful approach...

daniel
I think you can simply

include "http://localhost/tomcat/fooapp/foo.jsp";

(never tried it)

You can go the other way and do a remote include (doing whatever it is
you need to do in jsp) to access the PHP script via HTTP instead of the
local filesystem.

Jul 17 '05 #7
never mind - it looks like my problem is that (being a struts user) i was
using special jsp tags which were assuming things. all i had to do was take
out the tags and manually type in the code they output, with
action="http://www.myhost.com:8080/myApp/LogonSubmit.do".

i'm pretty excited about this.

daniel

"Blah Blah" <bl**@blahblah.com> wrote in message
news:J5********************@comcast.com...
looks like i broke out the champagne a little too early.
there's one key problem: submitting a form won't go to the servlet. so,
given the following html:

<FORM name="logonForm" action="/myApp/LogonSubmit.do" method="post">
User Name:<INPUT type="text" name="userName" /><br />
Password:<INPUT type="password" name="password" /><br />
<INPUT type="submit" value="Submit" />
</FORM>

it wants to go to http://localhost/myApp/LogonSubmit.do, not
http://localhost:8080/myApp/LogonSubmit.do.
is there any way around this?

if we can figure out a solution, this would allow me to mix and match php
and jsp in one file. otherwise, i'm going to have to go with a somewhat more painful approach...

daniel
I think you can simply

include "http://localhost/tomcat/fooapp/foo.jsp";

(never tried it)

You can go the other way and do a remote include (doing whatever it is
you need to do in jsp) to access the PHP script via HTTP instead of the local filesystem.


Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Nick | last post by:
I am working a new application...well actually a series of applications for my company. They want internal users to be able to go to a site and everything regarding security is transparent,...
24
by: trint | last post by:
add them into one PrintDocument: PrintDocument pd1 = new PrintDocument(); PrintDocument pd2 = new PrintDocument(); PrintDocument pdCombined = new PrintDocument(); pdCombined = pd1 + pd2;...
1
by: William Stacey [MVP] | last post by:
I need a bullet proof way to combine a root and a relative path to form a FQ rooted path (similar to a VDir in IIS). Path.Combine alone will not do the job in all cases. I also need to be sure...
13
by: Alison Givens | last post by:
....... that nobody knows the answer. I can't imagine that I am the only one that uses parameters in CR. So, my question again: I have the following problem. (VB.NET 2003 with CR) I have a...
5
by: pjfarley3 | last post by:
Hi all, First-timer here, with a question about composing XML and XSL. I have a need to send one XML file with NO external server references to an end-user browser window; i.e., I would like to...
8
by: Mir Nazim | last post by:
Hello, I need to write scripts in which I need to generate all posible unique combinations of an integer list. Lists are a minimum 12 elements in size with very large number of possible...
3
by: Schroeder, AJ | last post by:
Hello group, I am a relative PHP newbie and I am trying to combine two arrays together, but I also need to keep the keys of one array intact. What I am doing is two SNMP walks against a Cisco...
0
by: shinisen | last post by:
is it possible to combine jsp and asp?
10
by: Terry Olsen | last post by:
I need to be able to write to a file simultaneously from approximately 4 different threads. I'm working on a program that will download parts of a file and combine the parts. Each thread will have...
0
by: Andreas | last post by:
Hi When creating a windows application you get a specific file and folder structure when you compilte your code. I was wondering what sort of control (perhaps not using VS.NET but other tools...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.