Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ÔÚjspÖÐÖ±½ÓÊä³ö¶þ½øÖÆͼƬ


<%@ page info="Random Image Show"  
    pageEncoding="UTF-8" contentType="image/jpg"  
    autoFlush="true" buffer="16kb" session="false" import="java.io.FileInputStream"  
%><%   
String[] imgpaths = {   
    "D:/images/testimg1.jpg",   
    "D:/images/testimg2.jpg",   
    "D:/images/testimg3.jpg"  
};   
ServletOutputStream sos = response.getOutputStream();   
FileInputStream fis = new FileInputStream(imgpaths[(int) (Math.random() * imgpaths.length)]);   
byte[] buf = new byte[100];  //»º³åÇø´óС   
int len = 0;   
while ((len = fis.read(buf)) != -1) {   
    sos.write(buf, 0, len);   
}   
sos.flush();   
sos.close();   
fis.close();   
%>  
×¢Ò⣺ÔÚÓëout»ìÓÃʱ»á³ö´í£¬Òò´ËÔÚÓÃÍêgetOutputStreamÖ®ºóҪʹ
out.clear();
out = pageContext.pushBody();
ÏÂÃæÒ»¸öÀý×Ó
Îļþ´úÂëÈçÏ£º
OutputStream o=response.getOutputStream();
//Êä³öÎļþÓõÄ×Ö½ÚÊý×飬ÿ´Î·¢ËÍ500¸ö×Ö½Úµ½Êä³öÁ÷
byte b[]=new byte[500];
//ÏÂÔصÄÎļþ
File fileLoad=new File("f:/2000","book.zip");
//¿Í»§Ê¹Óõı£´æÎļþµÄ¶Ô»°¿ò
response.setHeader("Content-disposition","attachment;filename="+"book.zip");
//֪ͨ¿Í»§ÎļþµÄMOMEÀàÐÍ
response.setContentType("application/x-tar");
//֪ͨ¿Í»§ÎļþµÄ³¤¶È
long fileLength=fileLoad.length();
String length=String.valueOf(fileLength);
response.setHeader("Content_Length",length);
out.clear();
out = pageContext.pushBody();
//¶ÁÈ¡Îļþbook.zip£¬²¢·¢Ë͸ø¿Í»§ÏÂÔØ
FileInputStream in=new FileInputStream(fileLoad);
int n=0;
while((n=in.


Ïà¹ØÎĵµ£º

JSPÁ¬½ÓACCESSÊý¾Ý¿âµÄ¼òµ¥´úÂë

Á¬½ÓACCESSÊý¾Ý¿âµÄ¼òµ¥JSP´úÂ룺
  <%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<%@ page import="java.sql.*" %>
<%
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") ;
String url="jdbc:odbc:Driver={MicroSoft Access Drive ......

JSPÂÒÂëÎÊÌâ.

 ÔÚTomcatµÄserver.xmlµÄConnector²¿·ÖÌí¼ÓURIEncoding="GBK"£¬ÈçÏ£ºserver.xmlÌí¼ÓºóÄÚÈÝÈçÏ£º
Xml´úÂë 
<Connector  URIEncoding="GBK" port="8080"  
               maxThreads="150" m ......

JSP Standard Tag Libraries ʵ¼ùÀí½â

 ÔÚ±¾ÆªÎÄÕÂÖÐ,ÎÒÃǽ«»áÉîÈëÁ˽âÔÚ²»Í¬µÄTag LibraryÃèÊö·û(Tag Library Descriptors:TLDs)ÖÐʹÓø÷ÖÖ²»Í¬µÄtagµÄÇé¿ö.ÎÒÃǽ«»áÒÀ´ÎÑо¿ Ìõ¼þ¡¢Ñ­»·¡¢URL¡¢U18N¡¢XMLµÈtagµÄÓ÷¨¡£ÒÔ´ËÀ´Ìá¸ßÄã¶ÔJSTLµÄÈÏʶºÍÓ¦ÓÃÄÜÁ¦,ÔÚÔĶÁ±¾ÎÄÇ°£¬ÄãÓ¦¸Ã¶Ô JSP Tag LibÓÐËùÁ˽⣬²¢ÇåÎúÓйØJSTL£¨JSP Standard Tag Libraries£©µÄ»ù± ......

JSPÂÒÂëÖÕ¼«½â¾ö£¨ÊµÓã©

 JspÊÇÒ»¸öºÜÈÈÃŵĻ°Ì⣬µ«Èôó¶àÊýÈ˶¼Í·Í´µÄÊÇJSPÒ³ÃæÖеÄÂÒÂëÎÊÌ⣬±ÊÕßÉíÓÐÌå»á£»ÔøΪÁ˽â¾öÖÐÎÄÂÒÂëÎÊÌâÓôÃÆÁ˺ü¸Ì죬ÊÔÁ˺ܶ෽·¨¶¼²»ÐС£×îºóÔÚJSPרҵÈËÊ¿µÄ°ïÖúÏ£¬ÖÕÓÚ½â¾ö¡£Ö®ºó±ÊÕßÔø¶Ô´Ë×öÁËһЩСµÄÑо¿¡£  
  Ê×ÏÈÎÒÃÇÏÈÁ˽âÒ»ÏÂÎÊÌâµÄÔ­Òò¡£Ò»°ãÇé¿öÔÚÔÚÿ¸öJSPÒ³µÄÍ·²¿¶¼ÓÐÕâÑùÒ» ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ