Get Request source URL in PHP and Java [duplicate] - java

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'].

Related

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.

the method sendKeys(Keys.ARROW_DOWN) is not working when I execute my code on a server [duplicate]

This question already has answers here:
org.openqa.selenium.ElementNotInteractableException: Element is not reachable by keyboard: while sending text to FirstName field in Facebook
(5 answers)
Closed 3 years ago.
I'm using the method sendkey() and in local it works, but when I execute the same code on remote on a server, I have this error:
Element <div id="react-select-2--value" class="Select-multi-value-wrapper"> is not reachable by keyboard
driver.findElement(selectChurnReason).sendKeys(Keys.ARROW_DOWN);
You seem to have jumped to the wrong conclusion here - the error message is telling you that the element is not reachable, which means it's likely either not being displayed currently, off the screen, or is behind some kind of overlay.
There's nothing there to select the arrow down key couldn't be emulated.

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.

Sending data with Android to server [duplicate]

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

How can I read the contents of a webpage, not the source code of that page? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How can I use translate.google.com/ to translate the string in Java program?
I want to read the contents of a webpage ,not the source code of that page.
Contents means some comment or some lines etc.
EX:
http://translate.google.com/#en|bn|I%20love%20life .
From this page, I want to collect the translated line "আমি জীবন ভালবাসি"
How can I get this in JAVA ??
but you do want to read the contents of the source code, as it contains the content your looking for..
<span id="result_box" class="short_text" lang="bn"><span class="hps">আমি</span></span>
this is the node that contains the content of the translation...if you can build the url containing the un translated string, capture the response to that url and then find #result_box, you will have your content
I believe you can achieve this with HtmlUnit. Look at the method DomNode#asText().

Categories

Resources