사례 10-JSP 동적 출력 Excel 및 Word
7813 단어 java-web
표시할 텍스트:A.txt
- <br>
- 85 77 92<br>
- 95 88 75<br>
- 88 92 77<br>
- 96 85 88<br>
socre.jsp
- <%@ page contentType="text/html;charset=GB2312" %>
- <HTML>
- <BODY><Font size=5 >
- <P> ?
- <FORM action="show.jsp" method="post" name=form>
- <INPUT TYPE="submit" value="word" name="submit1">
- <INPUT TYPE="submit" value="excel" name="submit2">
- <INPUT TYPE="submit" value="other" name="submit3">
- </FORM>
- </FONT>
- </BODY>
- </HTML>
show.jsp
- <%@ page contentType="text/html;charset=GB2312" %>
- <HTML>
- <BODY>
- <% String str1=request.getParameter("submit1");
- String str2=request.getParameter("submit2");
- String str3=request.getParameter("submit3");
- if(str1.startsWith("word"))
- {response.setContentType("application/msword;charset=GB2312");
-
- }
- if(str2.startsWith("excel"))
- {response.setContentType("application/x-msexcel;charset=GB2312");
- }
- else{
- response.setContentType("text/html;charset=GB2312");
- }
- %>
- <jsp:include page="A.txt"/>
-
- </BODY>
- </HTML>