/*
* ReadFile
*
* Created on
*/
package jgwl
import java
import
import javax
import javax
import java
import jgwl
import java
import oracle
/**
*
* @author Roy Chen
* @version
*/
public class ReadFile extends HttpServlet {
/** Initializes the servlet
*/
public void init(ServletConfig config) throws ServletException {
super
}
/** Destroys the servlet
*/
public void destroy() {
}
/** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods
* @param request servlet request
* @param response servlet response
*/
protected void processRequest(HttpServletRequest request
throws ServletException
byte[] buf=new byte[
try{
Statement stmt=new DataBaseConnection()
ResultSet rs=stmt
response
//response
//**如要浏覽器直接另存為就不屏蔽上行
response
//**此處為文件的mime類型
//application/vnd
//application/vnd
ServletOutputStream out=response
InputStream in;
if(rs
in = blob
while(in
out
}
out
out
//**以下為網上看到的寫如文件的樣例
//==================
// while(rs
//ServletOutputStream sout = response
//InputStream in = rs
//byte b[] = new byte[
//for(int i = in
// sout
// in
// }
// sout
// sout
//}
//====================
//FileOutputStream file_out=new FileOutputStream(
//InputStream blob_in=blob
//int temp;
// while((temp=blob_in
// file_out
// blob_in
// file_out
//out
//out
stmt
}catch (SQLException e){
e
}
//PrintWriter out = response
/* TODO output your page here
out
out
out
out
out
out
out
*/
//out
}
/** Handles the HTTP <code>GET</code> method
* @param request servlet request
* @param response servlet response
*/
protected void doGet(HttpServletRequest request
throws ServletException
processRequest(request
}
/** Handles the HTTP <code>POST</code> method
* @param request servlet request
* @param response servlet response
*/
protected void doPost(HttpServletRequest request
throws ServletException
processRequest(request
}
/** Returns a short description of the servlet
*/
public String getServletInfo() {
return
}
}
From:http://tw.wingwit.com/Article/program/Oracle/201311/17924.html