How to serve a file with JSP?

后端 未结 4 1966
一个人的身影
一个人的身影 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:55

    To the point, just write the same code in JSP as you would do in a Servlet class. You can practically copypaste it. Only ensure that you are not writinig any template text to the stream, this includes linebreaks and whitespace outside the scriptlets. Otherwise it would get written to the binary file as well and corrupt it.

    If you have multiple scriptlet blocks, then you need to arrange them so that there's no linebreak between the ending %> of a scriptlet and the starting <% of the next scriptlet. Thus, e.g.

    <%@page import="java.io.InputStream" %><%
        //...
    %>
    

    instead of

    <%@page import="java.io.InputStream" %>
    <%
        //...
    %>
    

提交回复
热议问题