Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

provide interface to the other application

 
david arnold
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
david arnold
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see, thank you Segar for all the help.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic