I use a servlet to take argumentes with the doGet method from the user by clicking on a submit button. After that it sends him to my servlet's webpage. But to present the new webpage of the servlet I end up creating a page like this:
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
/* TODO output your page here. You may use following sample code. */
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1> Create your webpage here</h1>");
out.println("</body>");
out.println("</html>");
}
Is there a way to open a certain html file inside the Servlet? because this really narrows my ability to create a good looking page with javascript,css etc.
I tried using:
File htmlFile = new File(url);
Desktop.getDesktop().browse(htmlFile.toURI());
but the servlet wont let me because servlets are quirky and capricious. how can i overcome this obstacle?