That actually depends on what you want to do.
One way to do this is, fetch data from a "distant Java server" with Node and prepare a HTML page that your clients (browsers) will consume. Example, to set an input value, you would create:
- a fetch-data.js service, to fetch data from the distant Java server:
- a views/my-file.ejs html template (omitting a lot of boilerplate):
<html>
<body>
<input value="{{ someCount }}">
</body>
</html>
- a node.js server and handler for requests for this file:
import express from 'express';
import { fetchData } from './fetch-service';
const app = express();
app.set('view engine', 'ejs');
app.use(function(req, res) {
fetchData()
.then(data => res.render('my-file', data))
.catch(err => res.status(500).send('Server error.\n'));
});
app.listen(8080, () => console.log('Listening on 8080'));
You can then get your HTML with data here:
[zlatko@zlatko-desktop ~/tmp]$ curl localhost:8080
<html>
<body>
<input value="12345678">
</body>
</html>
[zlatko@zlatko-desktop ~/tmp]$
Now, by playing more with your fetch-service.js, you could transform the data in the way you like it. Playing more with the .ejs file, you can format the input, you can name it, add buttons and styles and javascript and other things that make a web page a web page.
Now, how to "read and clear a file/variable which Node also can" is a valid question, too, but it's more of a frontend question better answered on some frontend group.
Now, this is all very basic because you're not asking a specific question. So although JavaScript and Node.js are not very limited in what they can do, it might be challenging if you don't know what you want to achieve. So I would recommend studying a Node.js application design, maybe by following a good book, a video tutorial or other resource would help overcome that challenge.