byte[] Buffer=new byte[4096];
InputStream InData=null;
OutputStream outData=null;
int iSize; if(odbcRs.next())
{
outData=response.getOutputStream();
InData=odbcRs.getBinaryStream("BLOB字段");
response.setContentType("image/*");
while(true)
{
iSize=InData.read(Buffer);
if(iSize==-1)
{
break;
}
outData.write(Buffer,0,iSize);
}
outData.flush();
response.flushBuffer();
}
InputStream InData=null;
OutputStream outData=null;
int iSize; if(odbcRs.next())
{
outData=response.getOutputStream();
InData=odbcRs.getBinaryStream("BLOB字段");
response.setContentType("image/*");
while(true)
{
iSize=InData.read(Buffer);
if(iSize==-1)
{
break;
}
outData.write(Buffer,0,iSize);
}
outData.flush();
response.flushBuffer();
}
解决方案 »
- 求高手指点,网站的数据获取问题
- 指定目录下创建文件时的路径问题?
- 在做Struts 项目时 服务器没报错 但网页报了 ‘500’的错误,请高手 解惑
- WebSphere下getFormFile得到null,tomcat下则可以上传文件
- jsp电子商务网站
- JSp读取数据的问题
- 在lomboz-eclipse-emf-gef-jem-3.1RC2.zip这个已经集成了Eclipse3.1的LOMBOZ中
- 关于jsp 连接access 的问题
- 紧急求救ldap用户验证的问题!!急急急(在线等,搞定就结贴)
- 辞旧迎新~大散分!元旦快乐!
- 我的第一个问题!
- 为什么java.lang.NuberFormatException
InputStream InData=null;
int iSize,iLength;
iLength=request.getContentLength();
byte[] Buffer=new byte[iLength];
byte[] Byte_File;
if(iLength>0)
{
InData=request.getInputStream();
String ContentType=request.getContentType();
iSize=InData.read(Buffer);
if(iSize!=-1)
{
//数据处理开始
String FileData=new String(Buffer);
//正则字串:"name=\"";
//正则字串:"filename=\"";
String strSplit=ContentType.substring(ContentType.lastIndexOf("=")+1,ContentType.length());
String strSub[]=FileData.split(strSplit); String strElement;
int iBegin,iEnd;
iBegin=0;iEnd=0;
String FieldName,FieldValue;
int bTrue;
bTrue=0;
int iPos;
iPos=0;
int iLocation;
iLocation=0;
for(int iIndex=0;iIndex<strSub.length;iIndex++)
{
strElement=strSub[iIndex];
iBegin=strElement.indexOf("name=\"",0);
if(iBegin!=-1)
{
iEnd=strElement.indexOf("\"",iBegin+6);
FieldName=strElement.substring(iBegin+6,iEnd);
iBegin=strElement.indexOf("filename=\"",0);
if(iBegin!=-1)
{
bTrue=1;
}
//
iEnd=strElement.indexOf("\r\n\r\n",0);
if(bTrue==1)
{
iLocation=0;
iPos=FileData.indexOf("filename=\"",iPos);
iPos=FileData.indexOf("\n",iPos)+1;
iPos=FileData.indexOf("\n",iPos)+1;
iPos=FileData.indexOf("\n",iPos)+1;
iLocation=FileData.indexOf(strSplit,iPos)-4;
FieldValue=FileData.substring(iPos,iLocation);
byte[] Byte_File_=FieldValue.getBytes();
Byte_File=new byte[Byte_File_.length];
for(int kIndex=0;kIndex<Byte_File_.length;kIndex++)
{
Byte_File[kIndex]=Buffer[iPos+6+kIndex];
}
session.putValue(FieldName,Byte_File);
}
else
{
FieldValue=strElement.substring(iEnd+4);
session.putValue(FieldName,FieldValue.substring(0,FieldValue.indexOf("\n")-1));
}
bTrue=0;
}
}
//数据处理结束
String TypeValue,Id;
TypeValue=(String)session.getValue("TypeValue");
if(TypeValue!=null)
{
int iDoAction;
iDoAction=0;
if(TypeValue.indexOf("Add",0)!=-1)
{iDoAction=1;}
if(TypeValue.indexOf("Modify")!=-1)
{iDoAction=2;}
if(TypeValue.indexOf("Del")!=-1)
{iDoAction=3;}
odbcQuery="";
Id=(String)session.getValue("RecordId");
switch(iDoAction)
{
case 1:
odbcQuery="insert into Link(SiteName) values(null)";
odbcStmt.executeUpdate(odbcQuery);
odbcQuery="select * from Link";
odbcRs=odbcStmt___.executeQuery(odbcQuery);
odbcRs.last();
odbcRs.updateString("SiteName",(String)session.getValue("SiteName"));
odbcRs.updateString("SiteURL",(String)session.getValue("SiteURL"));
byte[] m_ByteArray=(byte[])session.getValue("SiteLogo");
odbcRs.updateBinaryStream("SiteLogo",new ByteArrayInputStream(m_ByteArray),m_ByteArray.length);
odbcRs.updateRow();
response.sendRedirect("/System/Link/List.jsp");
break;
case 2: