samedi 25 avril 2015

Expanding an existing webapp with Java Servlets

I have an existing and working web app. This web app is a combination of HTML, CSS, Javascript, various Javascript libraries (Jquery etc.), images, and fonts.

Using Tomcat and a Java servlet, I want to be able to deploy this web app. I also need to be able to serve up different web pages based on the URL (that's where the servlets come in, I think).

I found this SO post which shows how to deploy a web app using Tomcat through Tomcat's webapps directory. This works perfectly, except that it only displays the one index.html file, and there is no way to change the displayed HTML based upon the user entered URL.

I also found this other SO post which describes how to return static HTML from a Java servlet. The problem with this, is that it only returns the HTML file, and none of the supporting files (Javascript, CSS, images etc.) which are also necessary for the web app to function properly.

Is it possible for the servlet to return all necessary files along with the HTML file, so that the web app functions properly?




Aucun commentaire:

Enregistrer un commentaire