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

JSPÎļþÏÂÔØ¡¢ÉÏ´«

JSPÎļþÏÂÔØ-----------------------------------------------------------------
<%@ page contentType="text/html; charset=GBK"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page import="java.io.File"%>
<%@page import="java.io.InputStream"%>
<%@page import="java.io.FileInputStream"%>
<%
String path = request.getParameter("path") ;
if(path==null || "".equals(path)){
out.write("<mce:script type="text/javascript"><!--
") ;
out.write("alert('ÒªÏÂÔØµÄÎļþ²»´æÔÚ');") ;
out.write("history.go(-1);") ;
out.write("
// --></mce:script>") ;
}
String realPath = "c:/myfile/ÕýÎÄ.doc" ;
File file = new File(realPath) ;
if(!file.exists()){
out.write("<mce:script type="text/javascript"><!--
") ;
out.write("alert('ÒªÏÂÔØµÄÎļþ²»´æÔÚ');") ;
out.write("history.go(-1);") ;
out.write("
// --></mce:script>") ;
}else{
long l = file.length() ;
InputStream in = new FileInputStream(file) ;
String fs = file.getName() ;
if(in!=null){
response.reset();
response.setContentType("application/x-msdownload");
response.setHeader("Content-disposition","attachment; filename="+new String(fs.getBytes("GBK"),"iso8859-1"));
//ÒÔÉÏÊä³öÎļþÔªÐÅÏ¢
response.setContentLength((int)l); //ÉèÖÃÊäÈëÎļþ³¤¶È
byte[] b = new byte[2048];
int len = 0;
while((len=in.read(b)) >0)
response.getOutputStream().write(b,0,len); //Ïòä¯ÀÀÆ÷Êä³ö
in.close(); //¹Ø±ÕÎļþÊäÈëÁ÷
response.flushBuffer();
out.clear();
out = pageContext.pushBody();
}
}
%>
ÎļþÉÏ´«----------------------------------------------------------------------
Ìá½»Ò³Ãæ-------------
<form method="POST" enctype="multipa


Ïà¹ØÎĵµ£º

Jsp ÒýÓà css ÑùʽÎļþÎÞЧµÄÎÊÌâ½â¾ö

ÐÞ¸ÄÁËcss ÑùʽÎļþºó£¬ÖØÐÂä¯ÀÀ¸ÃjspÒ³Ãæ£¬·¢ÏÖÐÂÐ޸ĵÄÑùʽûÓÐÉúЧ¡£×ÜÒÔΪÊÇÏîÄ¿»º´æËùÒýÆðµÄ£¬ÓÚÊÇÇåÀíËùÓÐÏîÄ¿£¬ÖØÐ¹¹½¨ÏîÄ¿¡£²»ÐС£Ö´ÐÐserver µÄ publish »¹ÊDz»ÐС£ÓÃwindow µÄËÑË÷¹¦ÄÜ·¢ÏÖ³ýÁË WebContent Ŀ¼Óиà css ÎļþÍ⣬.metadata\.plugins\org.eclipse.wst.server.core\tmp1\webapps\ Ŀ¼ÏÂÒ²´æÔڸà c ......

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 ......

ÒýÓà JSP:contentType ÓëpageEncodingÇø±ð

pageEncoding
ÔÚJSP±ê×¼µÄÓï·¨ÖУ¬Èç¹ûpageEncodingÊôÐÔ´æÔÚ£¬ÄÇôJSPÒ³ÃæµÄ×Ö·û±àÂ뷽ʽ¾ÍÓÉpageEncoding¾ö¶¨£¬·ñÔò¾ÍÓÉcontentTypeÊôÐÔÖеÄcharset¾ö¶¨£¬Èç¹ûcharsetÒ²²»´æÔÚ£¬JSPÒ³ÃæµÄ×Ö·û±àÂ뷽ʽ¾Í²ÉÓÃĬÈϵÄISO-8859-1¡£
ContentType
ContentTypeÊôÐÔÖ¸¶¨ÁËMIMEÀàÐͺÍJSPÒ³Ãæ»ØÓ¦Ê±µÄ×Ö·û±àÂ뷽ʽ¡£MIMEÀàÐ굀 ......

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

 
£±.×îÖ±½Ó×î¼òµ¥µÄ£¬·½Ê½ÊǰÑÎļþµØÖ·Ö±½Ó·Åµ½htmlÒ³ÃæµÄÒ»¸öÁ´½ÓÖС£ÕâÑù×öµÄȱµãÊǰÑÎļþÔÚ·þÎñÆ÷ÉϵÄ·¾¶±©Â¶ÁË£¬²¢ÇÒ»¹ÎÞ·¨¶ÔÎļþÏÂÔØ½øÐÐÆäËüµÄ¿ØÖÆ£¨ÈçȨÏÞ£©¡£Õâ¸ö¾Í²»Ð´Ê¾ÀýÁË¡£
 
£².ÔÚ·þÎñÆ÷¶Ë°ÑÎļþת»»³ÉÊä³öÁ÷£¬Ð´Èëµ½response£¬ÒÔresponse°ÑÎļþ´øµ½ä¯ÀÀÆ÷£¬ÓÉä¯ÀÀÆ÷À´ÌáʾÓû§ÊÇ·ñÔ¸Òâ±£´æÎ ......

JSPÖи÷ÖÖÄÚÖöÔÏó

JSPÖи÷ÖÖÄÚÖöÔÏó
 
web½»»¥µÄ×î»ù±¾µ¥Î»ÊÇhttpÇëÇó¡£Ã¿¸öÓû§´Ó½øÈëÍøÕ¾µ½Àë¿ªÍøÕ¾Õâ¶Î¹ý³Ì³ÆÎªÒ»¸öHTTP»á»°£¬Ò»¸ö·þÎñÆ÷µÄÔËÐйý³ÌÖлáÓжà¸öÓû§·ÃÎÊ£¬¾ÍÊǶà¸öHTTP»á»°¡£×÷ÓÃÓò½âÊÍÈçÏ£º
1.application£º·þÎñÆ÷Æô¶¯µ½Í£Ö¹µÄÕâ¶Îʱ¼ä
2.session£ºHTTP»á·¢¿ªÊ¼µ½½áÊøµÄÕâ¶Îʱ¼ä
3.request£ºHTTPÇëÇó¿ªÊ¼µ½½áÊ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ