Java learning log 02

xiaoxiao2021-03-06  100

1. Develop web applications 1.1 Use virtual path knowledge points: 1.1.1 (context name, copy directly to WebApps directory, directly access folder) 1.1.2 WAR: Web program compression package production: D: / Hello > JAR CVF Hello.war *. * Access: Copy Hello.war to WebApps Directory, restart Tomcat, discovery will automatically decompress EAR: 1.1.3 web.xml:

mys // alias mys / myweb / myweb // Deployment Virtual Path 1.1.4 modification of form form: action = "MyWeb / MyWeb "// Do not add /, otherwise the representative is the top-level directory 1.2 servlet lifecycle knowledge point: JBoss: EJB container WebLogic: EJB container and JSP, servlet container connection pool: init, service, destroy is the container automatic call , Generally do not need to be overloaded. 1.3 SERVLET Jump RequestDispatcher Rd = NULL; // Defines Variable Rd = Req.getRequestDispatcher ("/ CHN"); // Jump to another class RD.Forward (REQ, RES); // Pass two variables

1.4 ServletContext is understood as a global variable, can put database connections, improve access efficiency, and implement shared web.xml (must be placed in front) Define variable CName GGYY InputNameToServlet.java Get variable servletcontext sc = getServletContext (); string cname = sc.getinitParameter ("cname"); 1.5 Using the web. Context-Param and StringTokenizer method in XML read and write text database Web.XML filename /web-inf/stud.txt ReadTxt.java in String filename = sc.getInitParameter ( "filename"); InputStream is = sc.getResourceAsStream (filename); BufferedReader br = new BufferedReader (new InputStreamReader (is)); while ( (s = br.readline ())! = null) {StringTokenizer St = New StringTokenizer (s); while (st.hasmoretoKens ()) {string ssn = st.nextToken (); string name = st.nextToken (); String sex = st.nextToken (); out.println ("" ssn "" SSN " Name " " SEX " ");}}

1.6 Using in Web.xml to load the container to start and close, destroy certain objects. 1.7 Using Session Management 1.7.1 Using Cookie 1.7.2 Use URL to override

Homework: Do a JSP message this to use Strus for MVC development information (no Java code in view, using JSP custom label)

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

New Post(0)