Extracting html response from jsp of another web app [duplicate] - java

This question already has answers here:
How to send HTTP request in Java?
(10 answers)
How to use java.net.URLConnection to fire and handle HTTP requests
(12 answers)
Closed 6 years ago.
I have a bizarre requirement. I need to download a jsp templates from another web app and get the dynamic html response as a string using my java app. I know how we can achieve this by ServletContext.getRequestDispatcher(), but getRequestDispatcher() cannot go to outside of the application and my application is not a web app. In short, my app has the data and the jsp template comes from another app. I'm thinking I can get the inputstream of this jsp template and write the dynamic data sonwhow? Any ideas?

Related

How to retrieve contents on a web page using Java [duplicate]

This question already has answers here:
Using Java to pull data from a webpage?
(5 answers)
Closed 5 years ago.
Can anyone suggest me a way to retrieve contents on a web page page using java?
I need to redirect to a web page, expand a block, and copy certain strings under it. Now I need to feed part of that string into another text box on a different page. How can this be done using java?
You should use Selenium (http://www.seleniumhq.org/). You can look up a tutorial on how to properly implement it for pulling data from websites. Assuming this is your own website, however, you can use a Socket.IO connection to communicate data.
Have you looked at Jsoup? https://jsoup.org/ it is a nice library for getting documents, parsing, etc.

How to consume a JSON web service in Java [duplicate]

This question already has answers here:
Parsing JSON from URL
(8 answers)
Closed 8 years ago.
I have a web service exposed to me which returns a json object.
I've been provided with a url http://address.to.web.service:8080/game
If enter this in any browser i get a json output.
In my code, I've already implemented logic to populate a web page but using a local json file.
I now need to wire it up with the output of the web service.
Can someone help me understand what might be the simplest way to go for this problem?
You need to connect to your webservice, read the full response and convert it to a JSON array. You do not specify which part of the problem you're having problems with.

How to call servlet from java code? [duplicate]

This question already has answers here:
How to consume REST in Java [duplicate]
(11 answers)
Closed 8 years ago.
Now I am forming the URL in the browser, and execute it via REST api like
localhost:9043/api/json?apiKey=699cccc3dcfb348fd369e083bcd7f2a4&Severity=all
and will get some JSON Object output.
Instead of working on browser, I need to give the URL in the java code itself and to get the json object output also in java code itself. I have searched but not found yet. Need some experts answer for my question.
it's just an HTTP call like any other, so you call it like any other HTTP call from a Java application, and get the results from that call like that as well.
So look up HttpURLConnection and go from there.

How to get started on making an http server? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Implementation of a web-server
I am trying to make an http server in java that can handle http requests. if the user types in http://www.example.com/Weather/94901 i want the program to be able to get the string "Weather/94901" then have my application process that and then display to results in the text of the webpage.
Why would you write a web server for that? In PHP, for example, you could use $_SERVER['PATH_INFO'] or in JSP request.getPathInfo()
Or if you really must, start with Jetty for example, an already existing Java HTTP server

making web browser [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Using java to create a web browser
Is there any way to make a webbrower using java?.
if yes pls give the idea about it.
Of course you can make a webbrowser by using java.
You would have to parse the html content of the pages you request.
If you're not interested in creating your own browser, here is a link how to display simple html files.

Categories

Resources