PhotoShow.java
资源名称:某公司的java培训教材 [点击查看]
上传用户:dinglihq
上传日期:2013-02-04
资源大小:99958k
文件大小:1k
源码类别:
Java编程
开发平台:
Java
- package bible.servlets;
- import javax.servlet.*;
- import javax.servlet.http.*;
- import java.io.*;
- import java.util.*;
- public class PhotoShow extends HttpServlet {
- private static final String CONTENT_TYPE = "text/html";
- public void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
- ServletContext ctx = this.getServletContext();
- String folder = request.getParameter("topic");
- File dir = new File(ctx.getRealPath("/images/" + folder));
- String[] dirList = dir.list();
- response.setContentType("text/html");
- PrintWriter out = response.getWriter();
- out.println("<html>");
- out.println("<head><title>PhotoShow</title></head>");
- out.println("<body>");
- for (int i=0; i<dirList.length; i++) {
- out.println("<p><img src="images/" + folder + "/" + dirList[i] + ""></p><p></p>");
- }
- out.println("</body></html>");
- }
- }