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
Ïà¹ØÎĵµ£º
Ê×ÏÈÊÇÌá½»Ò³Ãæ£ºÈý¸ö±íµ¥(form1,form2,form3)
<form name="form1" method="post" action="checklogin.jsp" class="niceform">
<input name="qx" type="hidden" value="3">
&nb ......
oracle+jspÖÐblobÀàÐÍ´æ´¢´óÎı¾ÎÊÌâ½â¾ö·½·¨
oracle ´æ´¢´óÎı¾Ò»Ö±ÊÇÒ»¸ö¼¬ÊÖµÄÎÊÌâ¡£
Ò»¡¢´æÊý¾Ý¿â£º
<%@page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%
//¶¨Òå±äÁ¿
java.sql.Connection conn; //Êý¾ ......
************************************************************************
·ÖÒ³µÄ´úÂ룺
--------------CSSÑùʽ--------------
<style type="text/css">
body,td,th {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #333;
}
body {
margin-left: 0px;
margin-top: 0px;
......
ÎÒÃÇÔÚдһ¸öjspÒ³Ãæ£¬ÒªÊ¹ÓÃstruts2±êÇ©£¬ÎÒÃÇÒªÊ×ÏÈÒªÔÚjspÒ³ÃæÍ·²¿·Å£º<%@ taglib prefix="s" uri="/struts-tags" %>£¬µ±È»Òª·Åstruts2µÄjar°üÁË¡£ÎÒÃÇ¿ÉÒÔË¢ÐÂһϴËÒ³Ãæ£¬±ÈÈç°ÑÕâ¸öÒ³Ãæ±£´æºóÔÙ´ò¿ª£¬Ä¿µÄÊÇÔÚдstruts2±êǩʱ£¬ÓÐstruts2±êÇ©×Ô¶¯Ìáʾ¹¦ÄÜ¡£
......