How to serve a file with JSP?

后端 未结 4 1952
一个人的身影
一个人的身影 2021-01-17 23:56

This may sound totally stupid, but is a case of real life :(

I\'m able to display a HTML table with a \"virtual\" link name.

Something like this:

         


        
4条回答
  •  庸人自扰
    2021-01-18 00:52

    Please, please, please don't do this.

    You're doing a disservice to your users.

    HTTP is amazingly rich in terms of what it can do with files. Caching, chunking, random access, etc.

    Take a look at something like FileServlet, and hammer that to fit. Yes, it's a Servlet, rather than a JSP, but this is what you want to do to be a good HTTP citizen.

    Some containers have other options you can use, you can hack Tomcats DefaultServlet, etc.

提交回复
热议问题