getstamp.jsp
上传用户:jhtang88
上传日期:2014-01-27
资源大小:28528k
文件大小:2k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. <%@page import="java.util.*"%>
  2. <%@page import="java.io.*"%>
  3. <%@page import="java.net.*"%>
  4. <jsp:useBean id="fchar" scope="page" class="cn.js.fan.util.StrUtil"/>
  5. <jsp:useBean id="cfgparser" scope="page" class="fan.util.CFGParser"/>
  6. <jsp:useBean id="fsecurity" scope="page" class="fan.util.fsecurity"/>
  7. <jsp:useBean id="privilege" scope="page" class="com.redmoon.oa.pvg.Privilege"/>
  8. <%
  9. String priv = request.getParameter("priv");
  10. if (priv==null)
  11. priv = "read";
  12. String user = fchar.UnicodeToGB(request.getParameter("user"));
  13. String pwd = request.getParameter("pwd");
  14. if (user==null)
  15. {
  16. if (!privilege.isUserPrivValid(request,priv))
  17. {
  18. out.println(fchar.makeErrMsg("     ʴ   "));
  19. return;
  20. }
  21. }
  22. else
  23. {
  24. if (!privilege.isUserPrivValid(user,fsecurity.MD5(pwd),priv))
  25. {
  26. out.println(fchar.makeErrMsg("     ʴ   "));
  27. return;
  28. }
  29. }
  30. String filename = fchar.UnicodeToGB(request.getParameter("filename"));
  31. if (filename==null) {
  32. //out.print(fchar.p_center("ȱ   "));
  33. //return;
  34. filename = user+".bmp";
  35. }
  36. filename = user+".bmp";
  37. cfgparser.parse("config.xml");
  38. Properties props = cfgparser.getProps();
  39. String documentpath = props.getProperty("documentpath");
  40. response.setContentType("application/bmp");
  41. response.setHeader("Content-disposition","attachment; filename="+filename);
  42. BufferedInputStream bis = null;
  43. BufferedOutputStream bos = null;
  44. try {
  45. bis = new BufferedInputStream(new FileInputStream(documentpath+"stamp/"+filename));
  46. bos = new BufferedOutputStream(response.getOutputStream());
  47. byte[] buff = new byte[2048];
  48. int bytesRead;
  49. while(-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
  50. bos.write(buff,0,bytesRead);
  51. }
  52. } catch(final IOException e) {
  53. System.out.println ( "  IOException." + e );
  54. } finally {
  55. if (bis != null)
  56. bis.close();
  57. if (bos != null)
  58. bos.close();
  59. }
  60. %>