0

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.

2
  • I don't see the point of adding Node to your stack if you already have a server running in Java, especially if it's not a technology you've used before. Something like Spring Boot will probably work just as well. Commented Sep 10, 2016 at 10:32
  • Hello LoudKing,Hope my answer helped you .If yes please accept the answer if not please let me know so that I can improvise on that and help you to give a better solution. Commented Aug 10, 2017 at 13:59

1 Answer 1

2

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);
})

;

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.