is it possible to combine jsp and php?

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default 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


    Blah Blah Guest

  2. Similar Questions and Discussions

    1. If I combine two PDFs...
      If I open a Press Quality PDF, Insert a second Press Quality page, is the PDF that results from a Save As itself Press Quality? Do I have some...
    2. Combine Databases
      How do you combine databases that use two different datasouces?
    3. combine applications
      I want to be able to create a document, say a company letterhead, from a creative program such as illustrator or Indesign and save it as a pdf. (I...
    4. Combine CSV files
      Hope someone can help me on this: I need to compare two cvs files that contains user profile information, but there are duplicates, what is the best...
    5. To combine or leave as is...
      My current application I am working on consists of 3 separate ASP pages. I'm posting data to each other page and using request.form to retrieve. ...
  3. #2

    Default Re: is it possible to combine jsp and php?

    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.


    Terence Guest

  4. #3

    Default Re: is it possible to combine jsp and php?

    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.
    >
    >
    Terence Guest

  5. #4

    Default Re: is it possible to combine jsp and php?

    "Blah Blah" <blah@blahblah.com> wrote in message
    news:<P5KdnZMlqKf2Fiei4p2dnA@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
    Nikolai Chuvakhin Guest

  6. #5

    Default Re: is it possible to combine jsp and php?

    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.lists@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.
    > >
    > >
    >

    Blah Blah Guest

  7. #6

    Default Re: is it possible to combine jsp and php?

    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.lists@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.
    >>>
    >>>
    >>
    >
    >
    Terence Guest

  8. #7

    Default Re: is it possible to combine jsp and php?

    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 [url]http://localhost/myApp/LogonSubmit.do[/url], not
    [url]http://localhost:8080/myApp/LogonSubmit.do[/url].
    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.
    > >
    > >
    >

    Blah Blah Guest

  9. #8

    Default Re: is it possible to combine jsp and php?

    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" <blah@blahblah.com> wrote in message
    news:J5SdnWlB1fRqaCai4p2dnA@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 [url]http://localhost/myApp/LogonSubmit.do[/url], not
    > [url]http://localhost:8080/myApp/LogonSubmit.do[/url].
    > 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.
    > > >
    > > >
    > >
    >
    >

    Blah Blah Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139