JSP servlet reference

xiaoxiao2021-03-06  41

-------------------------------------- JSP EXAMPLE --------- ------------------------------ <% @ page contenttype = "text / html; charSet = GB2312"%> <% @ Page errorpage = "ErrorPage.jsp"%> <% @ page import = "java.util. *"%> <%! string s = "hello"%> <% = s%> ---------- ------------------------------ Servlet Example ----------------- ---------------------- Import java.io. *; import javax.servlet. *; import javax.servlet.http. *; public class helloworld Extends httpservlet {public void doGet (HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {response.setContentType ( "text / html"); PrintWriter out = response.getWriter (); out.println ( "hello world");}} - -------------------------------------reference------------ -------------------------- Define Code <% @ Page ContentType = "text / html; charset = GB2312"%> import <% @ Page Import = "java.util. *, java.net. *"%> Error handling page <% @ Page ErrorPage = "ErrorPage.jsp"%> Using Taglib <% @ Taglib URI = "

http://www.jspcentral.com/tags

"prefix =" OFBIZ "%> or <% @ taglib URI =" OFBIZTAGS "prefix =" OFBIZ "%> .. Declaration, Note <%! INT i = 0;% > <%! Void mymethod () {}%> Using JavaBean <% = myBean.getage ()%> comment ] -> <% - Note -%> Contains File "%> "Flush =" true "/> " flush = "true"> <% @ page info = "Database handler"%> <% @ page import = "java.io. *"%> <% @ Page import = "java.util. *"%> <% @ Page Import = "java.sql. *"%> <% @ page import = "javax.servlet. *"%> <% @ page import = "javax.servlet.http. *"%>

<% try {// Load driver class.forname ("sun.jdbc.odbc.jdbcodbcdriver); string url =" jdbc: odbc: test "; //" test "is System DSN Name Connection Connection CON = DriverManager.getConnection (URL, "Administrator", "password"); // "Administrator", "password" is user name and password // then create a JDBC declaration statement stmt = con.createstatement (); String query = "CREATE TABLE COFFEES" "(COF_NAME VARCHAR (32)," "SUP_ID INTEGER," "Price Float," "SALES INTEGER," "Total Integer"; // Execute Stmt.executeUpdate (});} // output confirmation information Out.println ("Table Coffee Created");%> Page <% @ page [language = "java"] [eXtens = "package.class" ] [Import = "{package.class | package. *}, ..."] [session = "true | false"] [buffer = "none | 8kb | sizekb"] [autoflush = "true | false"] [ Isthreadsafe = "true | false"] [info = "text"] [errorpage = "relativeurl"] [contenttype = "mimeType [; charSet = characterset]" | "text / html; charSet = ISO-8859-1"] [ iSerrorPage = "true | false"]%> Req UEST ------------------------------------------------- --Request.getaTribute ("xxatt"); // ObjectRequest.setttribute ("xxatt", "xxval"); // voidRequest.getParameter ("xxparam"); ​​// StringRequest.getParameterNames (); // enumeration request. GetParameterValues ​​("xxparam"); ​​//string[Request.getRequestDispatcher ("iwantto.jsp" ).Forward (Request, response);

http: // localhost: 8080 / vps / control / testListrequest.getRemoteAddr () 127.0.0.1request.getMethod () GETrequest.getRequestURI () /vps/control/testListrequest.getProtocol () HTTP / 1.1request.getPathInfo () / testListSESSION -------------------------------------------------- -Session.getCreationTime () // longsession.getlastaccessedtime () // longsession.getid () // string

转载请注明原文地址:https://www.9cbs.com/read-70886.html

New Post(0)