jspµÄ9¸öÄÚ½¨¶ÔÏó
ÔÚjspÖв»Óö¨Òå¿ÉÒÔÖ±½ÓÓõľÍÊÇjspµÄ9¸öÄÚ½¨¶ÔÏóÁË
1£¬Request 2,Response 3,session 4,out 5,page
6,application 7,pageContext 8,config
9,exception
1¡¢Request¶ÔÏó
¸Ã¶ÔÏó·â×°ÁËÓû§Ìá½»µÄÐÅÏ¢£¬Í¨¹ýµ÷ÓøöÔÏóÏàÓ¦µÄ·½·¨¿ÉÒÔ»ñÈ¡·â×°µÄÐÅÏ¢£¬¼´Ê¹ÓøöÔÏó¿ÉÒÔ
»ñÈ¡Óû§Ìá½»µÄÐÅÏ¢¡£
µ±Request¶ÔÏó»ñÈ¡¿Í»§Ìá½»µÄºº×Ö×Ö·ûʱ£¬»á³öÏÖÂÒÂëÎÊÌ⣬±ØÐë½øÐÐÌØÊâ´¦Àí¡£Ê×ÏÈ£¬½«»ñÈ¡µÄ
×Ö·û´®ÓÃISO-8859£1½øÐбàÂ룬²¢½«±àÂë´æ·¢µºÒ»¸ö×Ö½ÚÊý×éÖУ¬È»ºóÔÙ½«Õâ¸öÊý×éת»¯Îª×Ö·û´®¶ÔÏó
¼´¿É¡£ÈçÏ£º
String
textContent=request.getParameter("boy");
byte
b[]=textContent.getBytes("ISO-8859-1");
textContent=new String(b);
Request³£Óõķ½·¨£º
1.01 getParameter(String strTextName) »ñÈ¡±íµ¥Ìá½»µÄÐÅÏ¢¡£
String strName£½request.getParameter("name");
1.02 getProtocol()
»ñÈ¡¿Í»§Ê¹ÓõÄÐÒé¡£
String strProtocol=request.getProtocol();
1.03
getServletPath() »ñÈ¡¿Í»§Ìá½»ÐÅÏ¢µÄÒ³Ãæ¡£
String
strServlet=request.getServletPath();
1.04 getMethod()
»ñÈ¡¿Í»§Ìá½»ÐÅÏ¢µÄ·½Ê½£¬get|post¡£
String strMethod = request.getMethod();
1.05 getHeade() »ñÈ¡HTTPÍ·ÎļþÖеÄaccept¡¢accept-encodingºÍHostµÄÖµ¡£
String strHeader = request.getHeader("accept");
1.06
getRermoteAddr() »ñÈ¡¿Í»§µÄIPµØÖ·¡£
String strIP = request.getRemoteAddr();
1.07 getRemoteHost() »ñÈ¡¿Í»§»úµÄÃû³Æ¡£
String clientName =
request.getRemoteHost();
1.08 getServerName() »ñÈ¡·þÎñÆ÷Ãû³Æ¡£
String serverName = request.getServerName();
1.09
getServerPort() »ñÈ¡·þÎñÆ÷µÄ¶Ë¿ÚºÅ¡£
int serverPort = request.getServerPort();
1.10 getParameterNames() »ñÈ¡¿Í»§¶ËÌá½»µÄËùÓвÎÊýµÄÃû×Ö¡£
Enumeration enum =
request.getParameterNames();
while(enum.hasMoreElements()){
String
s=(String)enum.nextElement();
out.println(s);
}
2¡¢Response¶ÔÏó
¶Ô¿Í»§µÄÇëÇó×ö³ö¶¯Ì¬µÄÏìÓ¦£¬Ïò¿Í»§¶Ë·¢ËÍÊý¾Ý¡£
2.1 ¶¯Ì¬ÏìÓ¦contentTypeÊôÐÔ
µ±Ò»¸öÓû§·ÃÎÊÒ»¸öJSPÒ³Ãæʱ£¬Èç¹û¸ÃÒ³ÃæÓÃpageÖ¸ÁîÉèÖÃÒ³ÃæµÄcontentTypeÊôÐÔʱtext/html£¬ÄÇôJSPÒýÇ潫°´ÕÕÕâ¸öÊôÐÔÖµ×ö³ö·´Ó¦¡£Èç¹ûÒª¶¯Ì¬¸Ä±äÕâ»»¸öÊôÐÔÖµÀ´Ï
Ïà¹ØÎĵµ£º
Ç°Ì᣺¼ÙÉèÄãµÄ Http µØַΪ http://192.168.0.1/ ÄãµÄ web Ó¦ÓÃΪ webapp £¬ÄÇôÄãµÄ web Ó¦Óà URL Ϊ http://192.168.0.1/webapp/
[ÎÊÌâ1]
[ÃèÊö]µ±ÔÚ jsp ÖÐÒýÈë css ʱ£¬Èç¹ûÆäÏà¶Ô·¾¶Ïà¶ÔÓÚµ±Ç° jsp ÎļþµÄ£¬¶øÔÚÒ»¸öºÍÕâ¸ö jsp µÄ·¾¶²»Ò»ÑùµÄ servlet ÖÐ forwarder Õâ¸ö jsp ʱ£¬¾Í»á·¢ÏÖÕâ¸ö css Ñùʽ¸ù±¾Ã»ÓÐÆ ......
JSPÓëServletÖ®¼äµÄ»á»°¸ú×Ù·½Ê½Óжà¸ö£¬×¢¶¨ËûÃǵÄͨÐÅ·½Ê½ÓжàÖÖ¡£
ÏÂÃæÏÈÀ´¿´¿´4ÖлỰ¸ú×Ù·½Ê½£º
Ò»£ºSession
´«ËͶˣº
HttpSession session=request.getSession();
sessio ......
ÔÚsql2000Öд´½¨´æ´¢¹ý³Ì£º
--ÇóÁ½ÊýÖ®ºÍ
create proc up_sum @a int ,@b int ,@result int output
as
select @result= @a+@b
µ÷Ó÷½·¨£º
...
CallableStatement cstmt=con.prepareCall("exec up_sum ?,?,?");
cstmt.registerOutParameter(3,java.sql.Types.INTEGER);
&nb ......
GBK±àÂë
GBK±àÂëÊÇÖйúÖƶ©µÄ¡¢µÈͬÓÚUCSµÄеÄÖÐÎıàÂëÀ©Õ¹¹ú¼Ò±ê×¼¡£GBK¹¤×÷С×éÓÚ1995Äê10Ô£¬Í¬Äê12ÔÂÍê³ÉGBK¹æ·¶¡£¸Ã±àÂë±ê×¼¼æÈÝGB2312£¬¹²ÊÕ¼ºº×Ö21003¸ö¡¢·ûºÅ883¸ö£¬²¢Ìṩ1894¸öÔì×ÖÂë룬¼ò¡¢·±Ìå×ÖÈÚÓÚÒ»¿â¡£
UTF-8±àÂë
UTF-8±àÂë¿ÉÒÔͨ¹ýÆÁ±ÎλºÍÒÆλ²Ù×÷¿ìËÙ¶Áд¡£×Ö·û´®±È½Ïʱstrcmp()ºÍwcscmp()µÄ·µ»Ø½ ......
֪ʶ׼±¸£º
JDBC·ÃÎÊÊý¾Ý¿âµÄ»ù±¾²½Öè
£¨1£©¡¢½«Êý¾Ý¿âµÄJDBCÇý¶¯¼ÓÔص½¹¤³ÌÀà¿âÖС£
£¨2£©¡¢¼ÓÔØJDBCÇý¶¯£¬²¢½«Æä×¢²áµ½DriverManagerÖС£ÏÂÃæÊÇһЩÖ÷Á÷Êý¾Ý¿âµÄJDBCÇý¶¯¼ÓÔØ×¢²áÂ룺
¢Ù¡¢oracleÊý¾Ý¿â
Class.forName(“oracle.jdbc.driver.OracleDriver”).newInstance();
¢Ú¡¢Sql Server 7.0/2000Êý¾ ......