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

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

Related

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

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?

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.

Is there a Java/PHP bridge? [duplicate]

This question already has answers here:
How do I add a Java backend to an existing PHP site without adding a tomcat server for Java Bridge?
(4 answers)
Closed 9 years ago.
I have created a program but i need to get a java program to run a php script with some arguments and then get the php script to send some arguments to the Java program. I know this question has been asked a lot of times but it seems like the only answer i can get is that php can do this but java cant but there must be a way to do it. Right?
You can run PHP from the command line:
http://php.net/manual/en/features.commandline.php
This should enable your Java application to run it, and capture it's return values.

Fetch data from other Website [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How do I make a raw HTTP request in Java?
I am monitoring a website which updates transaction data every few seconds, so for having better performance I need to store those data and analyze them (like plotting, etc.).
My question is how I can make a request to that server by Java EE and get the values which are available in a table in that site?
I should add that I do not search a solution by .net or php, and I have tried by JQuery, java HTTPRequest but I did not found the solution.
Any idea will be appreciated.
If they provide some sort of API/webservice that is best way to communicate,
if not and if the source site doesn't have any issue with the data you are taking from them you could use HTTP requests to get HTML response and parse the portion you want using JSoup
Have you actually tried anything yourself yet? SO is not a code generation tool.
That being said, this seems to be of interest: How do I make a raw HTTP request in Java?

Categories

Resources