Sending data with Android to server [duplicate] - java

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to send a JSON object over Request with Android?
I need a simple Android function that sends a JSON object to an IP address that is saved in the preferences of the phone.
Now, I know how to use prefs, I know how JSON works (theoretically), but I don't know how to actually send it to the server.
Note that, in this case, I don't actually care about security, encryption or anything else, just sending a simple JSON object with simple data such as "name", "latitude", "longitude", "time", "password".

example...
if your web service http url follow:
https://stackoverflow.com/questions/11863521.aspx
then enter data as
https://stackoverflow.com/questions/11863521.aspx?name="abc"
i hope this one help you, if use .net web service

Related

How is JWT stored on client side? [duplicate]

This question already has answers here:
Where to store JWT in browser? How to protect against CSRF?
(7 answers)
Closed 1 year ago.
I am new to JWT, I just return it as java object in JSON and made some filters so it can work just like session_id with Spring Security.
But I don't understand how is JWT stored on the client side, where does it go after the server response?
Is it automatically stored by all browsers in coockies?
Do all browsers support JWT?
I do appreciate your answer.
and made some filters so it can work just like session_id with Spring Security - if you want to use JWTs for sessions, please don't do that, and here's an article which will tell you why: http://cryto.net/~joepie91/blog/2016/06/13/stop-using-jwt-for-sessions/ If all you need is session, then stick with sessions. Using tokens will only complicate life for you and you will probably expose yourself to some token-related threats.
Otherwise, if you really want to stick with JWTs, then have a look at the answer linked in Yousaf's comment.

Karate API testing - unique value [duplicate]

This question already has an answer here:
How to set and retrieve the global variable's values in the feature file in karate?
(1 answer)
Closed 1 year ago.
I was wondering if anyone knows this karate problem I have.
Scenario: a user can create his profile
Given path '/signup'
And request { "username":"#(username)", "password":"#(password)" }
When method POST
Then status 200
the username has to have a unique value to get a 200 response. In this case it runs once but for obvious reasons doesn't run again.
Is there a way to hypothetically run the post request or perhaps use a dummy value?
Have you tried Postman? It's a program for testing APIs.

How to Display JSON Objects in Internet Explorer [duplicate]

This question already has answers here:
How can I convince IE to simply display application/json rather than offer to download it?
(9 answers)
Closed 8 years ago.
I have a RESTful web services application that reads from the database and returns objects in JSON format. It works flawless in Chrome and Firefox. Unfortunately, when I am testing it in Internet Explorer (IE), IE does not want to display JSON objects. It asks if I want to save it. I don't want to save it. I want to display JSON just like in Chrome and Firefox.
Could anyone please point me in the right direction on how to fix it? I read somewhere that I can tweak the properties of my IE browser in order to display JSON as plain text, but this is not an option for me. In the future the application will be used by other people, and some of them might use IE as their browser.
My code looks something like this:
#GET
#Path("/read")
#Produces("application/json")
public Something read(#QueryParam("page") String page){
//bluh bluh bluh
}
Thank you.
The question appears very similar to another question asked here
How can I convince IE to simply display application/json rather than offer to download it?
The second answer specified there seems to be what you want.
IE is not handling rightfully the content type application/json.
You could change the content type, accordingly to the user-agent but it's kind of dirty. You could also change it to text/javascript for everyone, it's a little less dirty.

Get Request source URL in PHP and Java [duplicate]

This question already has answers here:
HttpServletRequest - how to obtain the referring URL?
(4 answers)
Closed 7 years ago.
I want to determine the website from which the request to the particular website has been called.
For Example..I have a website www.ex.com.
Now this website link has been there on three websites www.a.com, www.b.com, and www.c.com.
Suppose one user has clicked the link from www.a.com to go to www.ex.com. Now I want to determine that the request has come from the www.a.com and then the page in www.ex.com will be displayed accordingly.
Similarly if the user has clicked the www.ex.com link from www.b.com then the page will be displayed accordingly.
So how can I determine this request source, means from which website www.ex.com has been called?
It is good if you will explain this using code in PHP and JAVA.
I don't know about in Java, but in PHP you can use $_SERVER['HTTP_REFERER'].

Request Param ordering [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Ordering of values in HttpServletRequest.getParameterValues()
We have J2EE based web application. On server side, we want to get parameters in exactly same order in which sent by client browser.
We tried request.getParameterMap() and request.getParameterNames() but these methods does not returns parameters in same sequence as send by client browser.
How can we get parameters in exactly same order in which sent by client browser?
Request parameters are stored internally in a map so you should make no assumptions about their order.
But why don't you just read them as they are and then sort them?
I am not sure why do we need to rely upon order of the parameters sent. Can you let know why thats required, may be you can solve the problem by alternative methods.
This is not even Java related.
You can't even rely on the browser to send the request params in a specific order.
Besides that as #mgamer noted, you can't make assumptions about the parameters order.
What you can do if you need to read the params in some predefined order, is to create some scheme in which you can do that easily. For example send a JSON object or use some simple format like param1=val&param2=another-val etc.

Categories

Resources