Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB
ÈÈÃűêÇ©£º c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 ×îÐÂÎÄÕ : jsp

ÔÚJSPÖÐÏÂÔØÎı¾Îĵµ

ͨ³££¬ÎÒÃÇÐèÒªÌṩһ¸öÎļþÏÂÔصÄʱºò£¬½öÐèÒªÒ»¸ö³¬Á´½Ó¾Í¿ÉÒÔ½â¾ö¡£
 
±ÈÈçexeÎļþ£¬Êó±ê×ó¼üµã»÷Á´½Ó¾Í»áÌáʾÄãÖ±½ÓÖ´Ðл¹ÊDZ£´æ£¬ÓÒ¼üÔò¿ÉÒÔÖ±½ÓÁí´æΪ¡£¡£¡£
 
µ«ÊÇÓÐÒ»²¿·ÖÎļþ£¬±ÈÈçtxtµÈ¿ÉÒÔÔÚä¯ÀÀÆ÷ÖÐÖ±½Ó´ò¿ªµÄÎļþ£¬ÄãÖ»ÄÜÓÃÊó±êÓÒ¼üµã»÷Á´½ÓÈ»ºóÁí´æΪµÄ·½Ê½È¥±£´æ¸ÃÎļþ£¬Èç¹ûÖ±½Óµã»÷×ó¼ü£¬¸ÃÎļþ¾ÍÔÚä¯ÀÀÆ÷Öб»´ò¿ªÁË¡£
 
ÔÚһЩÐèÇóÖУ¬ÎÒÃÇÐèÒªÈÃtxtÓµÓÐexeÎļþÀàËƵĶ¯×÷£¬¼´×ó¼üµã»÷ʱҲÈÃËüÌáʾ±£´æ»¹ÊÇ´ò¿ª¡£
 
ÍøÉϺܶàÎÄÕ¶¼Ìáµ½ÓÃjspsmartuploadÈ¥×öÕâ¼þÊÂÇ飬smartuploadµ±È»ÊǸöºÃ¶«Î÷£¬¿ÉÒÔÓõÄʱºò¾¡¹ÜÓ㬵«ÊÇËü²¢²»ÊDZØÐëµÄ£¬ÎÒÃÇÔÚjspÖпÉÒÔÖ±½ÓÉèÖÃresponseµÄHeader (Content-Disposition) À´´ïµ½Ä¿µÄ¡£ÏÂÃæÊÇÕû¸ö¹ý³Ì£º
 
1£©Ê×ÏÈÄãÒªÌṩһ¸öÏÂÔصÄÁ´½Ó£¬»òÕßbutton£¬È磺
<a href="download.jsp">ÎļþÏÂÔØ</a>
<button type="submit" onClick="window.open('download.jsp')">ÎļþÏÂÔØ</button>
×ÜÖ®£¬ÐèÒªÓÐÒ»¸ö·½·¨Ìøתµ½ÊµÏÖÎļþÏÂÔصÄjsp»òÕßservletÖС£
 
2£©ÔÚdownload.jsp£¨»òÕßʵÏÖͬÑù¹¦ÄܵÄservlet£©ÖУ¬´úÂëÈçÏ£º
<%@ page contentType="text/html ......

JSPÂÒÂëÎÊÌâÏà¹Ø

JSPÖгöÏÖÂÒÂ룬Ê×Ïȼì²éÒ»ÏÂpageEncodingºÍcontentTypeÁ½¸öÊôÐÔ£¬Á½¸öÊôÐÔµÄĬÈÏÖµ¶¼ÊÇISO-8859-1
pageEncodingÉèÖõÄÊDZàÒëJSPʱËùÓõıàÂ룬Èç¹ûÓÃĬÈϵıàÂë±àÒëÖÐÎÄ£¬ÄÇôÔÚJSP±àÒë½×¶ÎÒѾ­ÊÇÂÒÂëÁË¡£
contentTypeÉèÖõÄÊÇ·þÎñ¶Ë·¶Î§¸øä¯ÀÀÆ÷µÄÏÔʾ±àÂ룬ºÍÒ³ÃæÉÏÉèÖñàÂëÊÇÒ»ÑùµÄЧ¹û¡£ ......

JSPÓëSERVLETµÄ¹Øϵ

×ÛÊö£ºJava ServletÊÇJSP¼¼ÊõµÄ»ù´¡£¬¶øÇÒ´óÐ͵ÄWebÓ¦ÓóÌÐòµÄ¿ª·¢ÐèÒªJava ServletºÍJSPÅäºÏ²ÅÄÜÍê³É¡£ÏÖÔÚÐí¶àWeb·þÎñÆ÷¶¼Ö§³ÖServlet£¬¼´Ê¹²»Ö±½ÓÖ§³ÖServletµÄWeb·þÎñÆ÷£¬Ò²¿ÉÒÔͨ¹ý¸½¼þµÄÓ¦Ó÷þÎñÆ÷ºÍÄ£¿éÀ´Ö§³ÖServlet£¬ÕâµÃÒæÓÚJavaµÄ¿çƽ̨ÌØÐÔ¡£ÁíÍ⣬ÓÉÓÚServletÄÚ²¿ÒÔÏ̷߳½Ê½ÌṩÌṩ·þÎñ£¬²»±Ø¶ÔÓÚÿ¸öÇëÇó¶¼Æô¶¯Ò»¸ö½ø³Ì£¬²¢ÇÒÀûÓöàÏ̻߳úÖÆ¿ÉÒÔͬʱΪ¶à¸öÇëÇó·þÎñ£¬Òò´ËServletµÄЧÂʷdz£¸ß¡£
µ«Ëü²¢²»ÊÇûÓÐȱµã£¬ºÍ´«Í³µÄCGI¡¢ISAPI¡¢NSAPI·½Ê½Ïàͬ£¬Java ServletÒ²ÊÇÀûÓÃÊä³öHTMLÓï¾äÀ´ÊµÏÖ¶¯Ì¬ÍøÒ³µÄ£¬Èç¹ûÓÃËüÀ´¿ª·¢Õû¸öÍøÕ¾£¬¶¯Ì¬²¿·ÖºÍ¾²Ì¬Ò³ÃæµÄÕûºÏ¹ý³Ì½«±äµÃÎÞ·¨ÏëÏó¡£Õâ¾ÍÊÇSUN»¹ÒªÍƳöJSPµÄÔ­Òò¡£
ÈçºÎÕýÈ·Àí½âservlet£¿
servletµÄ»ù±¾¸ÅÄî
Ò»¡¢ServletµÄ½á¹¹
ÔÚ¾ßÌåÕÆÎÕservlet֮ǰ£¬Ðë¶ÔJavaÓïÑÔÓÐËùÁ˽⡣ÎÒÃǼÙÉè¶ÁÕßÒѾ­¾ß±¸Ò»¶¨µÄJava»ù´¡¡£ÔÚServlet APIÖÐ×îÖØÒªµÄÊÇServlet½Ó¿Ú£¨interface£©£¬ËùÓеÄservlets¶¼±ØÐëʵÏָýӿڣ¬Í¾¾¶ÓкࣺܶһÊÇÖ±½ÓʵÏָýӿڣ¬¶þÊÇͨ¹ýÀ©Õ¹Àà(class)À´ÊµÏÖ£¬Èç HttpServlet¡£ Õâ¸öServlet½Ó¿ÚÌṩÁËservletÓë¿Í»§¶ËÁªÏµµÄ·½·¨¡£Servlet±àдÕß¿ÉÒÔÔÚËûÃÇ¿ª·¢ servlet³ÌÐòʱÌṩ¸ü¶àһЩ»òËùÓеÄÕâÑ ......

jsp 9¸öÄÚÖöÔÏóÏê½â jsp »ù´¡ÖªÊ¶


1.request¶ÔÏó
¿Í»§¶ËµÄÇëÇóÐÅÏ¢±»·â×°ÔÚrequest¶ÔÏóÖУ¬Í¨¹ýËü²ÅÄÜÁ˽⵽¿Í»§µÄÐèÇó£¬È»ºó×ö³öÏìÓ¦¡£ËüÊÇHttpServletRequestÀàµÄʵÀý¡£
ÐòºÅ ·½ ·¨ ˵ Ã÷
1 object getAttribute(String name) ·µ»ØÖ¸¶¨ÊôÐÔµÄÊôÐÔÖµ
2 Enumeration getAttributeNames() ·µ»ØËùÓпÉÓÃÊôÐÔÃûµÄö¾Ù
3 String getCharacterEncoding() ·µ»Ø×Ö·û±àÂ뷽ʽ
4 int getContentLength() ·µ»ØÇëÇóÌåµÄ³¤¶È£¨ÒÔ×Ö½ÚÊý£©
5 String getContentType() µÃµ½ÇëÇóÌåµÄMIMEÀàÐÍ
6 ServletInputStream getInputStream() µÃµ½ÇëÇóÌåÖÐÒ»ÐеĶþ½øÖÆÁ÷
7 String getParameter(String name) ·µ»ØnameÖ¸¶¨²ÎÊýµÄ²ÎÊýÖµ
8 Enumeration getParameterNames() ·µ»Ø¿ÉÓòÎÊýÃûµÄö¾Ù
9 String[] getParameterValues(String name) ·µ»Ø°üº¬²ÎÊýnameµÄËùÓÐÖµµÄÊý×é
10 String getProtocol() ·µ»ØÇëÇóÓõÄЭÒéÀàÐͼ°°æ±¾ºÅ
11 String getScheme() ·µ»ØÇëÇóÓõļƻ®Ãû,Èç:http.https¼°ftpµÈ
12 String getServerName() ·µ»Ø½ÓÊÜÇëÇóµÄ·þÎñÆ÷Ö÷»úÃû
13 int getServerPort() ·µ»Ø·þÎñÆ÷½ÓÊÜ´ËÇëÇóËùÓõĶ˿ںÅ
14 BufferedReader getReader() ·µ»Ø½âÂë¹ýÁ˵ÄÇëÇóÌå
15 String getRemoteAddr() ......

linux java/jsp »ñȡϵͳµ±Ç°Ê±¼äÎÊÌâ

JSPÔ´´úÂë
 <%
   //»ñȡϵͳʱ¼ä
   //String ddate=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime());
   TimeZone tz = TimeZone.getTimeZone("ETC/GMT-8"); 
    TimeZone.setDefault(tz);
    java.util.Date date = new java.util.Date();//»ñµÃϵͳʱ¼ä.
          String nowTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);//½«Ê±¼ä¸ñʽת»»³É·ûºÏTimestampÒªÇóµÄ¸ñʽ.
          //Timestamp goodsC_date = Timestamp.valueOf(nowTime);//°Ñʱ¼äת»»
   %>
ÔÚwindowsÏÂÔËÐпÉÒÔ
µ«ÍøÒ³´«µ½linux:CentOS5.3ϳöÎÊÌâ
²î°ËСʱ£¬ºóÀ´²é×ÊÁÏ£¬
¸ÄÓÃÒÔÏ´úÂ룺
 <%
   //»ñȡϵͳʱ¼ä
   //String ddate=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime()); 
   //TimeZone tz = TimeZone.getTimeZone("ETC/GMT-8");& ......

linux java/jsp »ñȡϵͳµ±Ç°Ê±¼äÎÊÌâ

JSPÔ´´úÂë
 <%
   //»ñȡϵͳʱ¼ä
   //String ddate=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime());
   TimeZone tz = TimeZone.getTimeZone("ETC/GMT-8"); 
    TimeZone.setDefault(tz);
    java.util.Date date = new java.util.Date();//»ñµÃϵͳʱ¼ä.
          String nowTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);//½«Ê±¼ä¸ñʽת»»³É·ûºÏTimestampÒªÇóµÄ¸ñʽ.
          //Timestamp goodsC_date = Timestamp.valueOf(nowTime);//°Ñʱ¼äת»»
   %>
ÔÚwindowsÏÂÔËÐпÉÒÔ
µ«ÍøÒ³´«µ½linux:CentOS5.3ϳöÎÊÌâ
²î°ËСʱ£¬ºóÀ´²é×ÊÁÏ£¬
¸ÄÓÃÒÔÏ´úÂ룺
 <%
   //»ñȡϵͳʱ¼ä
   //String ddate=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime()); 
   //TimeZone tz = TimeZone.getTimeZone("ETC/GMT-8");& ......

linux java/jsp »ñȡϵͳµ±Ç°Ê±¼äÎÊÌâ

JSPÔ´´úÂë
 <%
   //»ñȡϵͳʱ¼ä
   //String ddate=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime());
   TimeZone tz = TimeZone.getTimeZone("ETC/GMT-8"); 
    TimeZone.setDefault(tz);
    java.util.Date date = new java.util.Date();//»ñµÃϵͳʱ¼ä.
          String nowTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);//½«Ê±¼ä¸ñʽת»»³É·ûºÏTimestampÒªÇóµÄ¸ñʽ.
          //Timestamp goodsC_date = Timestamp.valueOf(nowTime);//°Ñʱ¼äת»»
   %>
ÔÚwindowsÏÂÔËÐпÉÒÔ
µ«ÍøÒ³´«µ½linux:CentOS5.3ϳöÎÊÌâ
²î°ËСʱ£¬ºóÀ´²é×ÊÁÏ£¬
¸ÄÓÃÒÔÏ´úÂ룺
 <%
   //»ñȡϵͳʱ¼ä
   //String ddate=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime()); 
   //TimeZone tz = TimeZone.getTimeZone("ETC/GMT-8");& ......

jsp£ºinclude+filter

<jsp:include flush="true" page="Index.jsp">
      <jsp:param name="username" value="<%=request.getParameter("username")%>"/>
      <jsp:param name="unit" value="<%=request.getParameter("unit")%>"/>
   </jsp:include>
  /*
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package mypack.filters;
import java.io.IO ......
×ܼǼÊý:884; ×ÜÒ³Êý:148; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [139] [140] [141] [142] [143] [144] [145] 146 [147] [148]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ