开发者

Java listening for http messages

I have a java program that can ask client programs questions. I would like to add functionality by embedding the questions I might ask into a hyperlink so that they can be asked by clicking on that link (i.e. main use in powerpoint slides).

The generated link might look something like this: "http://localhost:port/questiondata/" The receiving program receives t开发者_开发百科he link, decrypts the question data to post the question.

Could I make it so that my program on localhost listening on the port could detect when that link is pressed/sent? There doesn't need to be any 2 way communication and it would always be asked on localhost, can I do that simply using java sockets listening on the port, or would i need to set up some form of webserver as a median.

I know very limited stuff about how http works, and I know tcp sockets need to be 2-way. Can anyone give me a recommendation of how I could possibly do this?


Sounds like you want an embedded HTTP server in your Java program (something like Jetty).

Or maybe you just need to make a web application and run that using something like Tomcat or Jetty.

Could I make it so that my program on localhost listening on the port could detect when that link is pressed/sent?

The web server would see the HTTP request that results in the user clicking on the link.

There doesn't need to be any 2 way communication

If you click a link in Powerpoint, it will open the page in a browser window. So your program gets to display something.


If you need a web server embedded inside your application you can write your own or embed one like Jetty inside your program

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜