简体   繁体   中英

Server process send output to node.js?

I am writing a web server application, which is a Java application listens to a port. Party A will be automatically sending requests to that port and the application will process the request and generate result. In the mean time, Party B will be reviewing the result in a web page. I am not quite familiar with web coding then I did some googling and got the impression that node.js is the popular way for the server to actively update web pages of client. Please correct me if I am wrong and also please give me some suggestions such as 1. which node.js module should be used to build such a web application. 2. How could a Java application would communicate with node.js server. Thanks in advance.

1) Please use express module of node js for web related application or any client server architecture.

2) To show the response on browser,you can go with res.send("Whatever response you need to send"). Please find some code snippets which may help you.

Please see following link as well.

Not getting any response in the browser

 const PORT = process.env.PORT || 3000; var express = require('express') , cors = require('cors'), app = express(); var bodyParser = require('body-parser'); app.use(cors()); var path = require("path"); app.set('port', PORT); app.listen(app.get('port')); app.use(bodyParser.urlencoded({ extended: false })) app.use(bodyParser.json()); console.log("Server is running at " + PORT); var res = ''; To check the response in browser app.get('/',function(req,res){ //Send this response to browser res.send(body); }) 

;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM