I'm building a website based on HTML, CSS & JS front-end and JAVA servlet Back-end.
The problem I am facing is that while sending a web page as a response to some request from the client, that web page is not completely static. I need to modify some parts of HTML according to data from the database and then I want to send that web page to the HTTP response either by redirecting to that HTML page or send it to the client line by line using getWriter()
function of HttpRequest object.
For both ways I need to take care of some parts of HTML code that need to changed. One way I could think of is that create another HTML file, read first static part of our HTML and write it to the new HTML. Then process dynamic HTML code and write it to the new HTML file. Again read static HTML and write it to new HTML file and so on.
But in this way, I don't what to do with JS & CSS files and other files like images that are being used by our HTML page that we want to send in response.