File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Android and JSP

 
Daniel Lima
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 252
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Daniel Lima
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Ulf!!!

Can you help me to solve this problem?

Thanks again!
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 252
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
kanakaraj chidhambarasamy,
Your post was moved to a new topic.
 
Nabajyoti Goswami
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic