Meaningless Drivel is fun!*
The moose likes Android and the fly likes Android and JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "Android and JSP" Watch "Android and JSP" New topic
Author

Android and JSP

Daniel Lima
Greenhorn

Joined: Feb 12, 2010
Posts: 14
Hi guys!

I'm making an app that must login on the server to run...

Here's the app code:



With this, my app can connect to the server. See the code on server:



Here's the problem.... the paremeters are always "null". Why? What I'm doing wrong?
Any help will be great!
Thank you all!
Hardik Trivedi
Ranch Hand

Joined: Jan 30, 2010
Posts: 252
Hi Daniel,

Once I have treid this stuff in Android. I found that code and pasting some code snippet. I hope it will be helpful to you.
Code in Android:

Where convert is a mehod which converts InputStream to String. I have intentionally not posted code for it.But google can help you out.
And below is my jsp file :


And I will suggest you to check port number and IP address once. And to generate response use Servlets. MVC-2 is the great concept use it man.


Tell me if you still need a help.
Daniel Lima
Greenhorn

Joined: Feb 12, 2010
Posts: 14
Hey Hardik, thank you very much!
It works!!!
Your code works perfectly!

But I have a doubt... You see a security problem by passing user and password in the url?
Thanks man!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41137
    
  45
You see a security problem by passing user and password in the url?

Yes, it is. URLs are part of the access logs kept by HTTP servers, leaving them at the mercy of anyone who has (legitimately or illegitimately) access to them. They're also kept in web browser, web server and proxy caches, making this a not-so-good approach.


Ping & DNS - my free Android networking tools app
Daniel Lima
Greenhorn

Joined: Feb 12, 2010
Posts: 14
Thank you Ulf!!!

Can you help me to solve this problem?

Thanks again!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41137
    
  45
I'm not exactly sure, but the way of adding parameters looks kind of complicated. Have you tried something like this?
Hardik Trivedi
Ranch Hand

Joined: Jan 30, 2010
Posts: 252
Hi Daniel and Ulf,
I know that is a security glitch.
I have solution too.

Ulf your previous code is I think almost right. There must be some other issue. I am sending a new code which I have just tried And it is working for me.
Android Code :



JSP Code :



Hope this will solve your security problem too.
Daniel Lima
Greenhorn

Joined: Feb 12, 2010
Posts: 14
Yesssssssssssss!!!

Perfect!!!

Thank you very much Hardik Trivedi! It works fine!
Thanks, thanks, thanks, thanks!

Ulf, thank you very much too!
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

kanakaraj chidhambarasamy,
Your post was moved to a new topic.


JBoss In Action
Nabajyoti Goswami
Greenhorn

Joined: Aug 19, 2011
Posts: 1
Hi, i am trying a lot with Android and Jsp using the example here. But JSP file is not able to get the value (which is set in NameValuePair in Android Activity) in request.getParamater. For me, the returned username and Password always null , unless i ran the JSP file by giving by name and password as
http://localhost:8080/TestJsp/login.jsp?userName=Naba,&password=Goswami
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Android and JSP
 
Similar Threads
Post the data to Server
Creating HTTP Post
read php session from android
unable to login to a website. tried both httpclient and defaulthttpclient
App wont connect to my database?