1<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "2pageencoding= "UTF-8"%>3<%@ pageImport= "Java.util.*"%>4<%@ pageImport= "Java.sql.*"%>5<%@ page errorpage= "errorpage.jsp"%>6<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >789<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">Ten<title>jsp Home </title> One A<body> - This is the JSP home page content -<%= "<br> Output"%> the<%= "<br> This is the Java string"%> -<%! - //!: Global variables (Special way of declaring) - +String str= "<br> This is a Java variable"; - //Access Counters + intI=0; A intRun () at { - returni++; - } -%> -<% - //Java Code Snippets in /* - Multi-line comments to */ + for(intm=0;m<10;m++) -{%> the *<%= "<br>" +m%> $<%}%>Panax Notoginseng<%=str%> -<br> i=<%= i++%> the<br> I=<%=run ()%> + A%> theThe result of 100+200 operation is <%= (100+200)%>, the operation is complete +<br> -<% $List<string> ls=NewArraylist<string>(); $Ls.add ("A"); -Ls.add ("B"); -Ls.add ("C"); theLs.add ("D"); - for(String s:ls)Wuyi { the%> -<%=s%> Wu<%}%> -<!--HTML comments-- About<%--Hidden Annotations--%> $<br> -<%intK=0; -String path= "inc/testinc2.jsp"; -%> A<%@ include file= "inc/testinc.jsp"%> +<jsp:include page= "<%=path%>" > the<jsp:param value= "Tom" name= "user"/> -</jsp:include> $ the<br>Action ID the<br>contains files 2 the<!--<jsp:include page= "inc/testinc2.jsp" ></jsp:include> the<jsp:param value= "Tom" name= "user"/> -<jsp:forward page= "errorpage.jsp" ></jsp:forward>--> in the<jsp:forward page= "test1.jsp" > the<jsp:param value= "tom1" name= "name"/> About<jsp:param value= "123456" name= "password"/> the</jsp:forward> the</body> the
1<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "2pageencoding= "UTF-8"%>3 4<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >567<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">8<title>insert title here</title>9Ten<body> One<% A //System.out.print ("Enter information to console"); - -String name=request.getparameter ("name"); theString password=request.getparameter ("Password"); -Out.print ("<br> received parameter name:" +name); -Out.print ("<br> accepted parameter password:" +password+ "<br>"); - //built-in objects +Out.print ("Enter information into the browser"); -String str= "Info"; + out.println (str); A out.println (str); at for(inti=0;i<10;i++) - { -Out.println ("<br> i=" +i); - } -%> -</body> in
1<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "2pageencoding= "UTF-8"%>3<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >456<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">7<title>insert title here</title>89<body>Ten One<form action= "test1.jsp" method= "POST" > AName: <input type= "text" name= "name" -<br><br><br> -Password: <input type= "password" name= "password" > the<br><br> -<input type= "Submit" value= "Submission" > -</form> -</body> +
1<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "2pageencoding= "UTF-8"%>3<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >456<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">7<title>insert title here</title>89<body>Ten One<form action= "test1.jsp" > AName: <input type= "text" name= "name" -<br><br><br> -Password: <input type= "password" name= "password" > the<br><br> -<input type= "Submit" value= "Submission" > -</form> -</body> +
Java Web Basics 2