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

JspʵÏÖÎļþÏÂÔØ¹¦Äܵķ½·¨

 
£±.×îÖ±½Ó×î¼òµ¥µÄ£¬·½Ê½ÊǰÑÎļþµØÖ·Ö±½Ó·Åµ½htmlÒ³ÃæµÄÒ»¸öÁ´½ÓÖС£ÕâÑù×öµÄȱµãÊǰÑÎļþÔÚ·þÎñÆ÷ÉϵÄ·¾¶±©Â¶ÁË£¬²¢ÇÒ»¹ÎÞ·¨¶ÔÎļþÏÂÔØ½øÐÐÆäËüµÄ¿ØÖÆ£¨ÈçȨÏÞ£©¡£Õâ¸ö¾Í²»Ð´Ê¾ÀýÁË¡£
 
£².ÔÚ·þÎñÆ÷¶Ë°ÑÎļþת»»³ÉÊä³öÁ÷£¬Ð´Èëµ½response£¬ÒÔresponse°ÑÎļþ´øµ½ä¯ÀÀÆ÷£¬ÓÉä¯ÀÀÆ÷À´ÌáʾÓû§ÊÇ·ñÔ¸Òâ±£´æÎļþµ½±¾µØ¡££¨Ê¾ÀýÈçÏ£©
 
 
<%
response.setContentType(fileminitype);
response.setHeader("Location",filename);
response.setHeader("Cache-Control", "max-age=" + cacheTime);
//filenameÓ¦¸ÃÊDZàÂëºóµÄ(utf-8)
response.setHeader("Content-Disposition", "attachment; filename=" + filename);

response.setContentLength(filelength);
OutputStream outputStream = response.getOutputStream();
InputStream inputStream = new FileInputStream(filepath);
byte[] buffer = new byte[1024];
int i = -1;
while ((i = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, i);
}
outputStream.flush();
outputStream.close();
inputStream.close();
outputStream = null;
%>
 
£³.¼ÈÈ»ÊÇJSPµÄ»°£¬»¹ÓÐÒ»ÖÖ·½Ê½¾ÍÊÇÓÃAppletÀ´ÊµÏÖÎļþµÄÏÂÔØ¡£²»¹ý¿Í»§Ê×ÏȵÃÐÅÈÎÄãµÄÕâ¸öAppletС³ÌÐò£¬ÓÉÕâ¸ö³ÌÐòÀ´½ÓÊÜÓÉservlet·¢ËÍÀ´µÄÊý¾ÝÁ÷£¬²¢Ð´Èëµ½±¾µØ¡£
servlet¶ËʾÀý
 
 
public void service(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType(" text/plain ");
OutputStream outputStream = null;
try {
outputStream = res.getOutputStream();
//°ÑÎļþ·¾¶ÎªsrcFileµÄÎļþдÈëoutputStreamÖÐ
popFile(srcFile, outputStream)) ;

} catch (IOException e) {
e.printStackTrace();
}
}
 
JApplet¶ËʾÀý
 
 
URLConnection con;
try {
//urlÊDZ»µ÷ÓõÄSERVLETµÄÍøÖ· Èç *.do
con = url.openConnection();
con.setUseCaches(false);
con.setDoInput(true);
con.setDoOutput(true);
con.setRequestProper


Ïà¹ØÎĵµ£º

JSPÓëSevletµÄÏ໥ͨÐÅ·½Ê½(¶þ)

Servlet£º
ÔÚServletÖУ¬Ìø×ªÔÚdoGet»òÕßdoPost·½·¨ÖÐʵÏÖ¡£
<1>redirectʵÏÖÒ³ÃæÌø×ª£º
 response.sendRedirect("/login.jsp");
 ·½·¨µÄ²ÎÊýÊÇÏà¶Ô·¾¶£¬É趨Õâ¸ö²ÎÊý¿ÉÒÔÊ¹Ò³ÃæÌø×ªµ½ÈκÎÒ³Ãæ£¬°üÀ¨www.baidu.comµÈÍøÂçÒ³Ãæ¡£
 Ìø×ªºóÄã¿ÉÒÔ·¢ÏÖµØÖ·À¸·¢ÉúÁ˱仯¡£
 µ×²ãÔ­Àí£ºÊ¹ÓÃredir ......

JSPÖеIJÎÊý´«µÝ·½·¨

£¨1£©ÀûÓÃ<jsp:param name="paramName" value="paramValue"></jsp:param>ÆäÖÐnameΪÓëÊôÐÔÏà¹ØÁªµÄ¹Ø¼ü´Ê£¬valueΪÊôÐÔµÄÖµ¡£
    ʾÀý£º´«³£Á¿×Ö·û´®<param name="userName" value="shilei"/>
    ʾÀý£º´«±äÁ¿ User user=new User("shilei");//UserÊÇÒ»¸öÀà
 &n ......

JSP±àÂ볣ʶ[ת]

GBK±àÂë
GBK±àÂëÊÇÖйúÖÆ¶©µÄ¡¢µÈͬÓÚUCSµÄеÄÖÐÎıàÂëÀ©Õ¹¹ú¼Ò±ê×¼¡£GBK¹¤×÷С×éÓÚ1995Äê10Ô£¬Í¬Äê12ÔÂÍê³ÉGBK¹æ·¶¡£¸Ã±àÂë±ê×¼¼æÈÝGB2312£¬¹²ÊÕ¼ºº×Ö21003¸ö¡¢·ûºÅ883¸ö£¬²¢Ìṩ1894¸öÔì×ÖÂë룬¼ò¡¢·±Ìå×ÖÈÚÓÚÒ»¿â¡£
UTF-8±àÂë
UTF-8±àÂë¿ÉÒÔͨ¹ýÆÁ±ÎλºÍÒÆÎ»²Ù×÷¿ìËÙ¶Áд¡£×Ö·û´®±È½Ïʱstrcmp()ºÍwcscmp()µÄ·µ»Ø½ ......

javascript µ÷Óà jspµÄ±äÁ¿

ÕÒÏÂÃæÐ´·¨¡£
×¢Ò⣬¼Óµ¥ÒýºÅ£¬µÚ2¸ö°Ù·ÖºÅ֮ǰûÓпոñ£¬¶øÔÚjspÖе÷ÓõĻ°Òª¿Õ¸ñ¡£
You may be get some help from the code below.
<%
String str="str";
%>

<script>
function accessVar(){
var varStr='<%=str%>';
alert(varStr);// here will diplay ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ