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

JSPÄÚÖöÔÏóÖ®request

HTTP ͨÐÅЭÒéÊÇ¿Í»§Óë·þÎñÆ÷Ö®¼äÒ»ÖÖÌá½»£¨ÇëÇó£© ÐÅÏ¢ÓëÏìÓ¦ÐÅÏ¢
£¨request/respone£©µÄͨÐÅЭÒé¡£ÔÚJSP ÖУ¬ÄÚÖöÔÏórequest ·â×°ÁËÓû§Ìá½»µÄÐÅÏ¢£¬
ÄÇô¸Ã¶ÔÏóµ÷ÓÃÏàÓ¦µÄ·½·¨¿ÉÒÔ»ñÈ¡·â×°µÄÐÅÏ¢£¬¼´Ê¹ÓøöÔÏó¿ÉÒÔ»ñÈ¡Óû§Ìá½»µÄÐÅ
Ï¢¡£
¿Í»§Í¨³£Ê¹ÓÃHTML ±íµ¥Ïò·þÎñÆ÷µÄij¸öJSP Ò³ÃæÌá½»ÐÅÏ¢£¬±íµ¥µÄÒ»°ã¸ñʽÊÇ£º
<FORM method= get | post action= “Ìá½»ÐÅÏ¢µÄÄ¿µÄµØÒ³Ãæ”>
Ìá½»ÊÖ¶Î
</FORM>…..
ÆäÖÐ<Form>ÊÇ±íµ¥±êÇ©£¬method È¡Öµget »òpost¡£Get ·½·¨ºÍpost ·½·¨µÄÖ÷ÒªÇø±ð
ÊÇ£ºÊ¹ÓÃget ·½·¨Ìá½»µÄÐÅÏ¢»áÔÚÌá½»µÄ¹ý³ÌÖÐÏÔʾÔÚä¯ÀÀÆ÷µÄµØÖ·À¸ÖУ¬¶øpost ·½·¨
Ìá½»µÄÐÅÏ¢²»»áÏÔʾÔÚµØÖ·À¸ÖС£Ìá½»ÊֶΰüÀ¨£ºÍ¨¹ýÎı¾¿ò¡¢ÁÐ±í¡¢Îı¾ÇøµÈ£¬ÀýÈ磺
<FORM action="tom.jsp" method= “post” >
<INPUT type="text" name="boy" value= “ok” >
<INPUT TYPE="submit" value=" Ëͳö" name= “submit”>
</FORM>
¸Ã±íµ¥Ê¹ÓÃpost·½·¨ÏòÒ³Ãætom.jsp Ìá½»ÐÅÏ¢£¬Ìá½»ÐÅÏ¢µÄÊÖ¶ÎÊÇ£ºÔÚÎı¾¿òÊäÈëÐÅ
Ï¢£¬ÆäÖÐĬÈÏÐÅÏ¢ÊÇ“ok”£»È»ºóµã»÷“Ëͳö”°´Å¥Ïò·þÎñÆ÷µÄJSP Ò³Ãætom.jsp Ìá½»ÐÅ
Ï¢¡£
request ¶ÔÏó¿ÉÒÔʹÓÃgetParameter(String s) ·½·¨»ñÈ¡¸Ã±íµ¥Í¨¹ýtext Ìá½»µÄÐÅÏ¢£¬
±ÈÈ磺
request.getParameter(“boy”);
Ò»¡¢»ñÈ¡¿Í»§Ìá½»µÄÐÅÏ¢
request ¶ÔÏó»ñÈ¡¿Í»§Ìá½»ÐÅÏ¢µÄ×î³£Óõķ½·¨ÊÇgetParameter(String s) ¡£
ÔÚÏÂÃæµÄÀý×Ó2ÖУ¬Example3_2.jsp ͨ¹ý±íµ¥Ïò×Ô¼ºÌá½»Ò»¸öÕýÊý£¬È»ºó¼ÆËãÕâ¸öÊýµÄƽ·½¸ù
Example3_2.jsp£º
<%@ page contentType="text/html;charset=GB2312" %>
<HTML>
<BODY bgcolor=cyan><FONT size=1>
<FORM action="Example3_2.jsp" method=post name=form>
<INPUT type="text" name="girl">
<INPUT TYPE="submit" value="Enter" name="submit">
</FORM>
<%String textContent=request.getParameter("girl");
double number=0,r=0;
if(textContent==null)
{textContent="";
}
try{ number=Double.parseDouble(textContent);
if(number>=0)
{r=Math.sqrt(number) ;
out.print("<BR>"+String.valueOf(number)+" µÄƽ·½¸ù£º");
out.print("<BR>"+String.valueOf(r));
}
else
{out.print("<


Ïà¹ØÎĵµ£º

¹ØÓÚ¸´Ñ¡¿òµÄÑéÖ¤ÓëjspÈ¡Öµ(תÔØ)

±íµ¥ÈçÏ£º
<form name="form1" action="test.jsp" method="post" onsubmit="return checkData();">
   <input name="checkall1" type="checkbox" value="0" onClick="checkAllBox(this);"/>È«Ñ¡<br>
   <input name="answer" type="checkbox" value="a"/>A<b ......

JSPÖж¨Ê±¹Ø±ÕÒ³ÃæµÄJS¿Ø¼þ


JS´úÂë
<script
type="text/javascript">
function closewindow(){
 window.returnValue = true;
 window.close();
}
function clock(){
 i = i -1;
 if(document.getElementById("info")){
  document.getElementById("info").innerHTML
......

JSPÄÚÖöÔÏó

JSP µÄÄÚÖöÔÏóÓУºresquest ¡¢response¡¢session¡¢ application ¡¢out¡£ÒÔÏÂÎÒÃǽ«
Ò»Ò»½éÉÜ¡£
response ºÍrequest ¶ÔÏóÊÇJSP µÄÄÚÖöÔÏó½ÏÖØÒªµÄÁ½¸ö£¬ÕâÁ½¸ö¶ÔÏóÌṩÁ˶ԷþÎñ
Æ÷ºÍä¯ÀÀÆ÷ͨÐÅ·½·¨µÄ¿ØÖÆ¡£Ö±½ÓÌÖÂÛÕâÁ½¸ö¶ÔÏóÇ°£¬ÒªÏȶÔHTTP ЭÒé----Word Wide
Webµ×²ãЭÒé×÷¼òµ¥½éÉÜ¡£
Word Wide WebÊÇÔõÑùÔËÐеÄÄØ£ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ