• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

execute php action and display html file from java file

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everyone,

I have a java web application and the operators already have their own connection form(it is a jsp file). What I would like to do is that when the operator connect to my java web application, enter their username, password and submit the form, mibew operator web page is displayed (http://localhost:9090/mibew/index.php/operator). I also would like to send the operator username, password ans session to mibew when the operator submit the form. Mibew is a web messenger application written in php.

So, when the user hit the button form the executed action is a php file located on another serveur(apache server) and then open a web page located into the same serveur . I do not know if that is possible but I really appreciate your idea and help

Please give me an idea how to do that. I really appreciate your help

Thank you very much.
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tiana Laine wrote:
So, when the user hit the button form the executed action is a php file located on another serveur(apache server) and then open a web page located into the same serveur . I do not know if that is possible but I really appreciate your idea and help



Welcome to the Ranch.

So you got JSP page with a form pointing to some PHP file on another server. That's pretty simple of course unless the servers aren't set up correctly.

Say you got
ServerA = Java / JSP page (eg Tomcat)
ServerB = PHP (Apache)

User loads on ServerA's JSP page -> click submit -> app goes to ServerB's PHP file -> open ServerB's PHP? page

Your form in the JSP page is just like any HTML form



The action will most likely need an absolute URL for it to work.

On the other hand, rather than pointing to the PHP directly, your java app's servlet can forward to the PHP page so it's transparent to the user.

 
Tiana Laine
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello K. Tsang,

You are very welcome. Thank you very much for your quick reply, I really appreciate that.
I am going to explain clearly my problem. I have 2 servers:

ServerA = Java / JSP page (Tomcat) --> my Java application
ServerB = PHP (Apache) --> 3rd party application, which is mibew messenger

What I am trying to do is that when I am logged from my java application(http://localhost:8084/myTest/), I need to post the formlogin and password to mibew (Server B) http://localhost:9090/mibew/index.php/operator and use my form to connect to mibew.
so the goal is I want to be automatically connected to mibew when I loggue from my application(so I want to wrokaround mibew form)

Mibew has MVC architecture and uses route system (I am trying to understand how it works)
On mibew side, there is a config file called, and here is the content:

## Home
home:

path: /

defaults:
_controller: Mibew\Controller\HomeController::redirectAction

home_operator:

path: /operator

defaults:
_controller: Mibew\Controller\HomeController::dashboardAction

_access_check: Mibew\AccessControl\Check\LoggedInCheck

## Log in

login:

path: /operator/login

defaults:
_controller: Mibew\Controller\LoginController::showFormAction

methods: [GET]



login_submit:

path: /operator/login

defaults:

_controller: Mibew\Controller\LoginController::submitFormAction

methods: [POST]

This my form:
<form name="loginForm" action="http://localhost:9090/mibew/index.php/operator" method="post">
<input type="text" name="formlogin" size="25" class="field-input" value="formlogin"/>
<input type="password" name="password" size="25" value="" class="field-input" autocomplete="off"/><br/><br/></td>
<input type="submit" value="Enter" name="submit" id="submit" class="submit-button-background login-button"/></td>


So when you submit the authetification form on mibew side, the main controller is "HomeController.php". This one redirects client's browser to operator's home page ("home_operator"):

public function redirectAction(Request $request)
{
return $this->redirect($this->generateUrl('home_operator'));
}

It executes HomeController.dashboardAction
method. This method renders the operator's home page and also has an access check, to check if the operator is connected or not.


showFormAction: is a method that allows to build the form on mibew side
submitFormAction: is the action form for mibew.

So here is my problem: when I submit my form, I am forwarded by default to mibew authetification form, which is I think normal
because it seems like there is an access check and if you are not loggued from mibew authentification, you are forwarded by default to mibew login form.
I tried to check the value of formlogin and password by doing $_POST["formlogin"] and $_POST["password"] on mibew side, and I realized that my data are not posted.

My goal is to bypass mibew authetification by using my java web application form and connect to operator home page "http://localhost:9090/mibew/index.php/operator" once I am connected.

Please let me know if you can give some idea, I really appreciate that.

Thank you very much
 
K. Tsang
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tiana Laine wrote:
So here is my problem: when I submit my form, I am forwarded by default to mibew authetification form, which is I think normal
because it seems like there is an access check and if you are not loggued from mibew authentification, you are forwarded by default to mibew login form.
I tried to check the value of formlogin and password by doing $_POST["formlogin"] and $_POST["password"] on mibew side, and I realized that my data are not posted.

My goal is to bypass mibew authetification by using my java web application form and connect to operator home page "http://localhost:9090/mibew/index.php/operator" once I am connected.



First you need to figure out in the PHP side if the form's data is transmitted POST or GET not even at all.

If PHP "redirects" to the login page if there is a session per se, I suspect whatever you entered previously is omitted.

Does PHP mibew have a login API you can use? Rather than relying on the mibew MVC. At the end of the day, you are doing single sign-on to mibew from java. If there is such API, you can call it in your java servlet and theoretically not need to touch PHP. Having this said, your form's action will point to java side servlet rather than PHP whatever.
 
Tiana Laine
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello again K. Tsang,

Honnestly, I am not familiar with php, I just try to understant the architecture of mibew messenger. It seems like all requests coming from outside mibew is redireted by default to the authetification web page. I do not know how to by pass that.
All that I noticed is that when the path: /operator is invoked, there is a check access and it allows to redirect you to the :

1- path: /operator/login wich can be :
defaults:
_controller: Mibew\Controller\LoginController::showFormAction --> so it is a GET method if you are not already logged. It builds the form

2- path: /operator/login wich can be :
defaults:
_controller: Mibew\Controller\LoginController::submitFormAction --> so it is a POST method if you are already logged. It submits the form

My idea is to find a solution to call "submitFormAction" method when I log from my java application.

It is hard because I am not familiar with php and I also try to understand the architecture of mibew messenger.

I know it is not that easy to understand what I have to implement but I would appreciate if you still have an idea to help me.

Again, thank you so much
 
K. Tsang
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After googling a bit, you seem to be in luck. There is a java mibew project at GitHub here that may be useful.

There isn't much doc for the java app by you should able to figure out what to call for getting the connection etc.

 
Tiana Laine
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello K. Tsang,
Thank you very much for your reply. Sorry for my late response, I was sick.
This java version is interesting but thing is my company really wants the php version so I have no choice.
Please let me know if you still have some idea. Thank you so much
 
When I was younger I felt like a man trapped inside a woman’s body. Then I was born. My twin is a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic