473,799 Members | 2,972 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 16974
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******* *************@c omcast.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******@fastm ail.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******@fastm ail.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
$fileResourc e = 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******** ************@co mcast.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
2724
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, however we will have brokers and customers that also need to connect and will require a username and password. In this case we were going to store their credentials in a SQL database. Internal users will have the ability to access the same resources...
24
8182
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; pdCombined.Print(); Thanks, Trint
1
5856
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 the no funny business can go on in the passed "path" that would produce a path not in the root (i.e. "..\..\dir1"). Here is my first stab at it, but not sure if this is too much or not enouph to ensure this. Any thoughts are welcome. TIA. ///...
13
2554
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 report with a multiple-value discrete value and a rangevalue. The report shows fine in the viewer, but when I hit the export to pdf
5
1321
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 be able to do something like having the href in the "xml-stylesheet" declaration be a "local" reference, something like this: <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="#Local_xsl"?>
8
5639
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 combination(12!) I hacked a few lines of code and tried a few things from Python CookBook (http://aspn.activestate.com/ASPN/Cookbook/), but they are hell slow.
3
8212
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 router in which I expect the script to return the interface number along with a small description of the interface type, like this: Array (
0
1156
by: shinisen | last post by:
is it possible to combine jsp and asp?
10
1687
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 an offset from zero and a length to write. None of the threads will overlap in the file position. Is it possible to have the file open (shared) by multiple threads? I'm guessing that i'd use a filestream with some sort of sharing. Looking for...
0
1004
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 and command line) I have to influence the way the output is made? At the moment I would get something like this App bin
0
9546
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10268
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10247
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9079
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7571
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5593
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.