简体   繁体   中英

Java servlet how to dump a static html page

I want to dump a static html page from a servlet. With php I would do something like

$dbdiv = <<<XYZ
<div id="mystaticdiv"></div>
</div>;

Then echo the XYZ

Can this be done with Java servletsa?

Use RequestDispatcher#forward() or include() , depending on whether it represents full or partial HTML content.

request.getRequestDispatcher("/WEB-INF/some.html").forward(request, response);

(note that the HTML page is hidden away in /WEB-INF to prevent direct access without invoking the servlet first)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM