JSPµÄÔËÐÐÄÚÄ»[ת]
JSPµÄÔËÐÐÄÚÄ»
¾³£ÓÐÅóÓÑÎÊÆð£¬JSPºÍServletÖ®¼äÓÐʲôÇø±ð£¬Á½ÕßÖ®¼äÓÖÓÐʲôÁªÏµ£¿ÆäʵServlet¼¼ÊõµÄ³öÏÖʱ¼äºÜÔ磬Êǵ±Ê±ÎªÁËJavaµÄ·þÎñÆ÷¶ËÓ¦Óöø¿ª·¢µÄ¡£´ó¼Ò¶¼ÖªµÀAppletÊÇÓ¦ÓÃС³ÌÐò£¬Servlet¾ÍÊÇ·þÎñÆ÷¶ËС³ÌÐòÁË¡£µ«ÔÚMicrosoft¹«Ë¾µÄASP¼¼Êõ³öÏÖºó£¬Ê¹Óà Servlet½øÐÐÏìÓ¦Êä³öʱһÐÐÐеÄÊä³öÓï¾ä¾ÍÏԵ÷dz£±¿×¾£¬¶ÔÓÚ¸´ÔÓ²¼¾Ö»òÕßÏÔʾҳÃæ¸üÊÇÈç´Ë¡£JSP¾ÍÊÇΪÁËÂú×ãÕâÖÖÐèÇóÔÚServlet¼¼ÊõÖ®ÉÏ¿ª·¢µÄ¡£¿É¼û£¬JSPºÍServletÖ®¼äÓÐ×ÅÄÚÔÚµÄѪԵ¹Øϵ£¬ÔÚѧϰJSPʱ£¬Èç¹ûÄܹ»×¥×¡ÕâÖÖÁªÏµ£¬¾ÍÄܸüÉî¿ÌµØÀí½âJSPµÄÔËÐлúÀí£¬´ïµ½Ê°빦±¶µÄЧ¹û¡£
±¾ÎĽ«Í¨¹ý¶ÔÒ»¸öJSPÔËÐйý³ÌµÄÆÊÎö£¬ÉîÈëJSPÔËÐеÄÄÚÄ»£¬²¢´ÓȫеÄÊӽDzûÊöһЩJSPÖеļ¼ÊõÒªµã¡£
HelloWorld.jsp
ÎÒÃÇÒÔTomcat 4.1.17·þÎñÆ÷ΪÀý£¬À´¿´¿´×î¼òµ¥µÄHelloWorld.jspÊÇÔõôÔËÐеġ£
´úÂëÇåµ¥1£ºHelloWorld.jsp
HelloWorld.jsp
<%
String message = "Hello World!";
%>
<%=message%>
¡¡¡¡Õâ¸öÎļþ·Ç³£¼òµ¥£¬½ö½ö¶¨ÒåÁËÒ»¸öStringµÄ±äÁ¿£¬²¢ÇÒÊä³ö¡£°ÑÕâ¸öÎļþ·Åµ½TomcatµÄwebappsROOTĿ¼Ï£¬Æô¶¯Tomcat£¬ÔÚä¯ÀÀÆ÷ÖзÃÎÊhttp://localhost:8080/HelloWorld.jsp£¬ä¯ÀÀÆ÷ÖеÄÊä³öΪ“HelloWorld!”
¡¡¡¡ÈÃÎÒÃÇÀ´¿´¿´Tomcat¶¼×öÁËʲô¡£×ªµ½TomcatµÄworkStandalonelocalhost\_Ŀ¼Ï£¬¿ÉÒÔÕÒµ½ÈçϵÄHelloWorld_jsp.java£¬Õâ¸öÎļþ¾ÍÊÇTomcat½âÎöHelloWorld.jspʱÉú³ÉµÄÔ´Îļþ£º
¡¡¡¡´úÂëÇåµ¥2£ºHelloWorld_jsp.java
package org.apache.jsp;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import org.apache.jasper.runtime.*;
public class HelloWorld_jsp extends HttpJspBase {
......
public void _jspService(HttpServletRequest request,
HttpServletResponse response)throws java.io.IOException, ServletException
{
JspFactory _jspxFactory = null;
javax.servlet.jsp.PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page = this;
JspWriter _jspx_out = null;
try {
_jspxFactory = JspFactory.getDefaultFactory();
response.setContentType("text/html;charset=ISO-8859-1");
pageContext = _jspxFactory.getPageContext(this, request, resp
Ïà¹ØÎĵµ£º
´ÓÍøÉϲéÕÒ×ÊÁÏjava/jsp»ñµÃ¿Í»§¶Ë(IE)Íø¿¨MACµØÖ·µÄ·½·¨´ó¸ÅÓÐÈýÖÖ¡£
1¡¢Í¨¹ýÃüÁʽ£¬ÔÚ¿Í»§¶ËÖ´ÐÐIpconfig µÈµÈ
2¡¢Í¨¹ýActiveXµÄ·½·¨
3¡¢Í¨¹ýÏò137µÄ¶Ë¿Ú·¢ËͲéѯָÁîµÄ·½·¨
¼ò½é£º
µÚÒ»ÖÖ·½·¨,ÔÚÕæÕýÓõ½Ê±ºò²»ÖªµÀΪʲô»ñµÃmacµØÖ·µÄÖ¸Áî×èÈûÁË,²»ÍùϼÌÐøÖ´ÐС£¶øÇÒËÙ¶ÈÊÇÕâÈýÖÖ·½·¨ÖÐ×îÂýµÄÒ»ÖÖ¡£
´úÂëÈçÏ ......
<%@ page autoFlush="false" contentType="text/html;charset=utf-8" language="java" import="java.io.*,java.awt.Image,java.awt.image.*,com.sun.image.codec.jpeg.*,java.sql.*,com.jspsmart.upload.*,java.util.*,java.io.FileInputStream,java.io.FileOutputStream,java.awt.*"%>
<%@ page import="com.b ......
ÓеÄÒ³ÃæÐèҪÿ´Îµã»÷½øÈ¥¶¼¶¯Ì¬¸üУ¬¶ø²»ÊǶÁÈ¡»º´æÖеÄÒ³Ãæ¡£
ÔÚJSPÖпÉÒÔÕâÑùʵÏÖ£º
<%
request.setCharacterEncoding("GBK");
response.addDateHeader("Expires",0);
response.setHeader("Pragma","no-cache");
response.setHeader("Cache-Control","no-cache");
%> ......
¸Õ¿ªÊ¼Ñ§jsp£¬×öµÄÒ»µãÌý¿Î±Ê¼Ç¡£
1.jspÈý´óÖ¸Áî
<%@ page ~~~~~~~~ %>
<%@ include file=""%>
<%@ taglib url="" prfix=""%>
2.if(username.equals(""))
out.println("ÐÕÃû²»ÄÜΪ¿Õ£¬Çë<a href=javascript:history.back()>·µ»Ø")£»
&&·ÀÖ¹Ö±½ÓÔÚä¯À ......
×ܵÄÀ´½²£¬JavaSever PagesTM£¨JSP£©ºÍ ΢ÈíµÄActive Sever Pages£¨ASP£©ÔÚ¼¼Êõ·½ÃæÓÐÐí¶àÏàËÆÖ®´¦¡£Á½Õ߶¼ÊÇΪ»ùÓÚWEBÓ¦ÓÃʵÏÖ¶¯Ì¬½»»¥ÍøÒ³ÖÆ×÷ÌṩµÄ¼¼Êõ»·¾³Ö§³Ö¡£Í¬µÈ³Ì¶ÈÉÏÀ´½²£¬Á½Õ߶¼Äܹ»Îª³ÌÐò¿ª·¢ÈËÔ±ÌṩʵÏÖÓ¦ÓóÌÐòµÄ±àÖÆÓë×Ô´ø×é¼þÉè¼ÆÍøÒ³´ÓÂß¼ÉÏ·ÖÀëµÄ¼¼Êõ¡£¶øÇÒÁ½Õ߶¼Äܹ»Ìæ´úCGIʹÍøÕ¾½¨ÉèÓë·¢Õ¹±äµÄ½ÏΪ ......