GeeCON Prague 2014*
The moose likes Struts and the fly likes provide interface to the other application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "provide interface to the other application" Watch "provide interface to the other application" New topic
Author

provide interface to the other application

david arnold
Ranch Hand

Joined: Apr 10, 2009
Posts: 133
Hi,

I am working on a Struts project which has a jsp webpage for user to input user name and password to log in the application. Now someone want to call my application from the other appliction, he want to call my application by providing user name, password and the other parameter to log in my application without going through the Login page.

Well, I only know that transfer form from jsp to action, in this case, how can i get his parameter so i could do the action.

Thanks for the help.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

tony xue wrote:Now someone want to call my application from the other appliction, he want to call my application by providing user name, password and the other parameter to log in my application without going through the Login page.

And what is that "other" application will be? a web app or desktop app ?
1. If its web app, then provide the complete URL of login action of your web app, keeping the login page fields same .
2. If desktop app, then for basic things use java.net.HttpURLConnection, OR if you want some advanced things, try using Apache HttpClient

[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
david arnold
Ranch Hand

Joined: Apr 10, 2009
Posts: 133
Thank you Sagar very much.

The application is web app, i am new in web app, at first I did not understand your words " keeping the login page fields same ", later when I tried to access request parameters, I found the request parameters are passed as form data if the parameters are same as form bean name, maybe that is what you meant. Thanks again for the help! Appreciate it!
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

tony xue wrote:at first I did not understand your words " keeping the login page fields same ", later when I tried to access request parameters, I found the request parameters are passed as form data if the parameters are same as form bean name, maybe that is what you meant.

Yes,
What I meant is this:



I never tried this, but give it a try !
david arnold
Ranch Hand

Joined: Apr 10, 2009
Posts: 133
Thank you Sagar. The other web app use VB to call my app, I just need a URL as you said. The URL is like /AppRoot/LoginAction.do?user=tony&password=123. When I got this URL in my Action class, I found the ActionForm contain the value of user and password, I think maybe because user and password are the bean of the form, and I define the form for this Action in struts-config file, so the URL value are passed in as form data, I am still not sure why it work in this way. If you know, please let me know, if not, does not matter, since the problem has been solved. Anyway, thanks for the kind help!
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

tony xue wrote: When I got this URL in my Action class, I found the ActionForm contain the value of user and password, I think maybe because user and password are the bean of the form, and I define the form for this Action in struts-config file, so the URL value are passed in as form data, I am still not sure why it work in this way.

Yes, the Java bean is used to either populate or transfer the HTML FORM data to the server side POST action.
That bean is also called as DTO(Data Transfer Object).

AppRoot/LoginAction.do?user=tony&password=123.

And this is GET action and you're passing the form data as a request parameter, thus exposing the important data, which is considered as bad practice. Never use GET action for login info submission.
david arnold
Ranch Hand

Joined: Apr 10, 2009
Posts: 133
I see, thank you Segar for all the help.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Welcome buddy !!
 
GeeCON Prague 2014
 
subject: provide interface to the other application