An example of using JSP + JavaBean + XML

xiaoxiao2021-03-06  19

This example is to refer to the relevant documents related to JSP on XML on some websites, combined with some individual experiences. The content involved is that the partial code of the background management end of the company's internal solution system is mainly concentrated in the management of basic information about the restaurant. The cause of this example itself is part of my joke I am in the original company and colleagues. I also express my missing ideas for those who have worked together. The example itself is a program of the B / S structure running under Tomcat 4.01 platform. Regarding the configuration of Tomcat, not explained here. Just explain the directory structure of the related files and folders. Directory Structure Description: / Tomcat / WebApps / Canyin / ---- Main Directory / Tomcat / WebApps / Canyin / JSP / ----- JSP File Directory / Tomcat / WebApps / Canyin / JSP / Admin / ---- - Realize the storage of the JSP files in the background / Tomcat / WebApps / Canyin / Web-INF / CLASS / CANYIN / ------ JavaBean file storage directory / Tomcat / WebApps / Canyin / Data / ----- XML file storage directory / tomcat / webApps / root / ----- Tomcat launch file storage folder, only stored index.html file files simple instructions: /tomcat/webapps/canyin/data/Users.xml ---- - Record user information / Tomcat/webapps/canyin/data/rebapps.xml ----- Record the basics of the restaurant / Tomcat/webapps/root/index.html ----- Home, page appear in the input box, ask users Enter your username, password /tomcat/webapps/canyin/jsp/loginjudge.jsp ----- User authentication page, determine the page according to the user name and password, is transferred to the background management, or the front desk client. In this example, once the user identifies that there is administrative privilege, you can enter the background management, jump to the base information management page of the restaurant, simplify the description. /Tomcat/webapps/canyin/jsp/Admin/admin_rest.jsp ----- Restaurant Basic Information Management page, management restaurant name, phone, address, etc. Information / Tomcat / WebApps / Canyin / Web-INF / CLASSES / CANYIN / ChecksessionBean.class ---- Background Management Detection Sign User identity SESSION value, if it is not an administrator, jump back to the landing page. /Tomcat/webapps/canyin/web-inf/classes/canyin/web-inf/classes/canyin/connxmlbean.class ----- Connect XML file / Tomcat/webapps/canyin/web-inf/classes/canyin/writexmlbean.class ----- Write Detailed introduction of XML file files and accompanying code descriptions.

/Tomcat/webapps/canyin/data/Users.xml code: - Description: Field meaning Is a username, password, and user's identity / Tomcat/webapps/canyin/data/restaurants.xml code: - - Shanghai Ting fast food restaurant 021-76546726

Broadway Plaza - Shangri-La Hotel 021-2312134
Nanjing Road 1023 Description: property is a record There are a total of many records in the Restaurants.xml file, each new one, whether it is deleted, this value increases 1, as if the usage of the habitual use of the database is automatically added to 1 ID item. Used to give a new attribute assigned a unique value. Other fields are more meaningful.

/ Tomcat/webapps/root/index.html (simple HTML code) code: OddWorld Catering System </ Title> <meta http-equiv = "Content-Type" Content = "Text / HTML; Charset = GB2312 "> </ head> <body οnlοad =" javascript: dataform.username.focus ()> <div align = "center"> <table width = "100%" border = "0" cellspacing = "0" cellpadding = "0" height = "22"> <type <td width = "1"> <img src = "images / top_r1.gif" width = "62" height = "22"> </ td > <Td width = 150 align = "center"> Catering system login </ td> <td> <img src = "images / top_r2.gif" width = "294" height = "22"> </ td> </ tr> </ table> <br> <br> <table width = "300" border = "0" cellspacing = "1" cellpadding = "0"> <tr> <td height = "200" valign = "top" Align = "center"> <p align = "center"> <table width = "100%" border = "0" cellspacing = "1" cellpadding = "5" bgcolor = # 999999 class = a9px> <tr> <TD BGColor = "# Efefef"> Catering system login </ td> </ tr> <tr> <td bgcolor = "# ffffff" Valign = "TOP" align = "center"> <table width = "100%" border = "0" Cellspacing = "0" Cellpadding = "0"> <form name =</p> <p>DataForm method = post action = '' Canyin / JSP / Loginjudge.jsp ''> <tr> <TD width = "100"> <b> Login Name: </ b> </ td> <TD> <input maxlength = 16 name = "username" class = stedit value = "joard"> </ td> </ tr> <tr> <td width = "100> <b> password: </ b> </ td> <td> <Input Class = STEDIT MAXLENGTH = 16 Name = "Userpass" type = password value = "oddworld"> </ td> </ tr> </ form> </ table> <BR> <table border = 0 cellpadding = 0 cellspacing = 0> <tbody> <tr> <td> <input class = stbtm name = update onclick = "javascript: if (checkform () == false;" TYPE = Button value = "login"> </ td> <TD> </ TD> <TD> <input class = stbtm na Me = Submit OnClick = "JavaScript: window.location.href = '' index.asp? myjoke = 1 '';" Type = Button value = "Modify password"> </ td> <TD> </ td> </ Tr> </ tbody> </ table> <br> </ td> <</p> <p>/ TR> </ table> </ td> </ tr> </ table> </ div> </ body> </ html> <script language = javascript> <! - function checkform () {var checkblank = / ^ (/ s * | (/) | (/.))*$/; if ("DataForm.Username.value) {alert (" The login name can not be empty! "); return false;} (CHECKBLANK.TEST (DataForm.Userpass.value) {alert ("Password cannot be empty!"); Return false;} Window.DataForm.Submit ();} -> </ script> Description: Put the user name and User Password Submit to /Tomcat/webapps/canyin/jsp/Loginjudge.jsp /Tomcat/webapps/canyin/web-inf/classes/canyin/eb-inf/classes/canyin/checksessionBean.Class (code is the corresponding Java file) package canyin; import javax.servlet. http.HttpSession; import javax.servlet.http.HttpServletRequest; public class checkSessionBean {private boolean bolCheckPass = false; private HttpServletRequest request = null; public boolean checkSessionBean (HttpServletRequest request, String strSessionName, String strCheckValue) {public boolean checkSessionBean (HttpServletRequest request) {Httpsession session = request.getse ssion (false); return (bolCheckPass); if (strSessionName == null || strCheckValue == null) {return (bolCheckPass);} else {if (!! session = null && session.getValue (strSessionName) = null) { Bolcheckpass = session.getValue (strsssionname) .Equals (strCheckValue);}}}}}}}}}}}}}}}}}}}} Description: Check if the value of the session name of the parameter is equal to whether the value of the parameter incoming field is equal.</p> <p>/Tomcat/webapps/canyin/web-inf/classes/canyin/connxmlbean.class code: package canin; import javax.xml.parsers. *; import javax.xml.transform. *; import javax.xml.transform.dom. DOMSource; import javax.xml.transform.stream.StreamResult; import org.w3c.dom *;. public class connXmlBean {private DocumentBuilderFactory factory = null; private DocumentBuilder builder = null; private Document doc = null; public connXmlBean () {} public String connXml (String xmlFileName) {String strExc = ""; try {factory = DocumentBuilderFactory.newInstance (); builder = factory.newDocumentBuilder (); doc = builder.parse (xmlFileName); doc.normalize ();} catch ( Exception e) {strexc = E.toTOString ();} return (strexc);} PUBLIC Document getXMLDoc () {return (doc);}} Description: Open a specified XML file / Tomcat / WebApps / Canyin / Web-INF / classes / canyin / writeXmlBean.class Code: package canyin; import javax.xml.parsers *; import javax.xml.transform *; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.. .StreamResult; import java.io.File; import org.w3c.dom *;. Public class writeXmlBean {public writeXmlBean () {} public String writeXml (Document doc, String xmlFileName) {String strExc = ""; try {TransformerFactory tfactory = TransformerFactory.newInstance (); Transformer transformer = tfactory.newTransformer (); DOMSource source = new DOMSource (doc); StreamResult result = new StreamResult (new File (xmlFileName)); transformer.transform (source, result);} catch ( Exception E) {strexc = e.toString ();} return (stres);}} Description: Write the contents of the DOM to a specified XML file.</p> <p>/ Tomcat/webapps/canyin/jsp/webapps/cany.jsp code: <% - ODDWORLD Catering Management System (Simplified Chinese Version) December 1, 2002 Copy Right by Joard Ast Loginjudge.jsp Function: User Identity Verification, Base / Duality Different Identities Differentiated in the DATA / User.xml file is transferred to the background management page, or the customer points.</p> <p>-%> <% @ page contenttype = "text / html; charset = GB2312"%> <% @ page language = "java" import = "javax.xml.parsers. *"%> <% @ Page Import = " Org.w3c.dom. * "%> <% @ page import =" canin. * "%> <jsp: usebean id =" xmlbean "class =" canyin.connxmlbean "scope =" page "/> <% session. setMaxInactiveInterval (1800); Document doc; NodeList users; String strExc = ""; String strUsername, strPassword; strUsername = (String) request.getParameter ( "username"); strPassword = (String) request.getParameter ( "userpass"); / / The verification data is empty if (strusername == "| | strpassword ==") {out.println ("<script language = 'javascript'"); out.println ("Alert) The 'username or password has a null value!'); "); Out.println (" Window.Location.href = '/ index.html' '; "); out.println (" </ script> ") }} Xmlbean.connxml ("WebApps / Canyin / Data / Users.xml"); DOC = XMLBean.GetXmldoc (); try {users = doc.getlementsBytagname ("user"); for (int i = 0; i <users.getLength (); i ) {Element user = (element) Users.Item (i); string stratrnamevalue = user.getattributenode ("name"). getnodeValue (); string ST rAtrPassWordValue = user.getAttributeNode ( "password") getNodeValue ();. String strAtrRoleValue = user.getAttributeNode ( "roles") getNodeValue ();. if (strAtrNameValue.equals (strUsername) && strAtrPassWordValue.equals (strPassword)) {if ( StratrroleValue.equals ("admin"</p> <p>)) {OUT.PRINTLN ("<script language = '' javascript '"); out.println ("Alert (' Welcome administrator login system! ');"); Out.println ("</ Script> "); // Set the session (SESUSERROLE) indicating the user identity, the administrator is admin session.settribute (" SESUSERROLE "," admin "); // Jump to the management page response.sendredirect (" admin / admin_restire .jsp "); return;} else {// Set the session (SSSUSERROLE) indicating the user's identity, the administrator is User Session.setttribute (" SESUSERROLE "," User "); // Jump to the normal user page response. Sendredirect ("index.jsp"); return}} else {output Language = 'javascript' ""); Out.Println ("Alert ('' username or password error! '' ); "); Out.println (" History.go (-1); "); out.println (" </ script> "); return;}}} catch (exception e) {strexc = E.toTRING );}%> Description: ....... / Tomcat / WebApps / Canyin / JSP / Admin / Admin_Rest.jsp code: <% - ODDWORLD Catering Management System (Simplified Chinese Version) December 1, 2002 COPY Right by Joard Ast Admin_Rest.JSP Function: Background Management Page, Restaurant Management Page.</p> <p>-%> <% @ page contenttype = "text / html; charset = GB2312"%> <% @ page language = "java" import = "javax.xml.parsers. *"%> <% @ Page Import = " Javax.xml.transform. * "%> <% @ page import =" org.w3c.dom. * "%> <% @ page import =" canyin. * "%> <% @ include file =" ../ ../include/sys_dialog.jsp "%> <JSP: usebean id =" checksessionBean "class =" canin.checksessionBean "scope =" page "/> <jsp: usebean id =" xmlbean "class =" canin.connxmlbean " Scope = "page" /> <jsp: usebean id = "Writexmlbean" class = "canin.writexmlbean" scope = "page" /> <% // calibration user identity, judgment is an admin IF (! ChecksessionBean. ChecksessionBean (Request, "SESUSERROLE", "Admin"))) {Out.print ("You don't have managed permissions!", "/ index.html"); return;} // from the restaurant data file REST.XML Get related data Document Doc; Nodelist Restaurants; String Stract; INT INTID = 0; String Stroperation = "Show"; // Accepts external incoming parameters stract = (string) Request.GetParameter ("ACT"); xmlbean.connxml ("WebApps / Canyin / Data / Restaurants.xml"); DOC = XMLBean.getxmldoc (); restaurants = doc.getlements; "RESTAURANT"); / / Determine the operation of RESTAURANT.XML files according to external incoming parameters IF (stract! = null) {if (stract .equals ( "addnewDo")) {String strName; String strPhone; String strAddress; Text textseg; strName = (String) request.getParameter ( "name") trim ();. strPhone = (String) request.getParameter ( "phone ") .trim (); straddress = (string) Request.getParameter (" address "). TRIM (); // Data check IF (strname ==</p> <p>NULL) {OUT.PRINT (ShowDialog! ")))))); return;} if (strphone == null) {Out.print (" ShowDialog! ")); Return; } / * If (straddress == null) {OUT.PRINT (ShowDialog! ")); Return;} * / // check data uniqueness for (INT i = 0; i < Restaurants.getlength (); i ) {Element restaurant = (Element) Restaurants.Item (i); if ((String) Restaurant.getlementsBytagname ("name"). item (0) .GetfirstChild (). getnodevalue ()) . Equals (Strname)) {OUT.PRINT (ShowDialog ("Restaurant Name Duplicate!")); Return;} else {ife ((String) Restaurant.getlementsBytagname ("name"). Item (0) .GetfirstChild () .GETNODEVALUE ()). Equals (strphone)) {out.print (showdialog ("Restitute phone repeat!")); return;}}} // Get an existing record number, give new restaurant record settings unique Increasing ID attribute int INUM = 0; Element RESTNUM = (ELEMENT) Doc.GetElementSbyTagName ("Restaurants"). Item (0); Intnum = Integer.Parseint (RESTNUM.GETTRIBUTENODE ("Num"). GetnodeValue ()); INTNUM = 1; // Add 1 RESTNUM.GETATTRIBUTENODE ("NUM"). setNodeValue (String.Valueof (INTNUM)); // New Node Element newRestaurant = doc.createElement ( "restaurant"); Attr newArrId = doc.createAttribute ( "id"); // Attribute newArrId = new Attribute ( "id", String.valueOf (intNum)); textseg = doc.createTextNode ( String.valueOf (intNum)); newArrId.setValue (String.valueOf (intNum)); newRestaurant.setAttributeNode (newArrId); Element newName = doc.createElement ( "name"); textseg = doc.createTextNode (strName); newName. appendchild (textseg); newrestaurant.appendchild (newname); element newphone = doc.createElement ("Phone"); textSeg =</p> <p>doc.createTextNode (strPhone); newPhone.appendChild (textseg); newRestaurant.appendChild (newPhone); Element newAddress = doc.createElement ( "address"); textseg = doc.createTextNode (strAddress); newAddress.appendChild (textseg); newRestaurant .appendChild (newAddress); doc.getDocumentElement () appendChild (newRestaurant);. // calls the bean xml file written to the corresponding writeXmlBean.writeXml (doc, "webapps / canyin / data / restaurants.xml"); response.sendRedirect ( Request.getRequesturi ()); return;} f (stract.equals ("modido")) {string strname; string strphone; string straddress; text textseg; int modiid; // Record to modify the record is Item (i) Which int INTI = 0; strname = (string) Request.getParameter ("name"). Trim (); strphone ("phone"). Trim (); straddress = (string) Request .getParameter ("address"). Trim (); ModiId = INTEGER.PARSEINT ("RECORDID"). Trim ()); // Data Check IF (StrName == Null) {Out.print (showdialog ("Restaurant name cannot be empty!"))); Return;} if (strphone == null) {Out.print (ShowDialog ("Restaurant Phone is not empty!")); Return;}}} (ModiID == 0) {Out.print ("You want to modify the record of the restaurant!")); return;} / * if (strass == null) {Out.print (showdialog "Restaurant can not be empty!")); Return;} * / // flag display records There is a boxlean recording = false; // Verify the uniqueness for (INT i = 0; i <restaurants.getLength); i ) {Element restaurant = (Element) Restaurants.Item (i); if (Integer.Parseint (Restaurant.GetAttributeNode ("ID"). getNodeValue ()) == modiid) {recordexist = true; inti = i;} if ((String) Restaurant.GetelementsBytagname ("Name"</p> <p>) .item (0). Getfirstchild (). getnodeValue ()). Equals (Strname) && integer.Parseint ("ID"). getnodeValue ())! = modiid) {out.print (showdialog) Restaurant name repetition! "); Return;} else {IF ((String) Restaurant.GetElementsBytagName (" name "). Item (0) .GetfirstChild (). GetnodeValue ()). Equals (strphone) && integer.Parseint (Restaurant "). getnodeValue ())! = modiid) {Out.print (ShowDialog (" Resting Telephone Repeat! ")); Return;}}} if (! recordexist)}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} if (! ("You have to modify the restaurant's record does not exist!"); Return;} Else {// Recording changes Try {ELEMENT MODIRESTAURANT = (Element) Restaurants.item (inti); ModiRestaurant.getlementsBytagname ("name") .item (0) .getFirstChild () setNodeValue (strName);. modiRestaurant.getElementsByTagName ( "phone") item (0) .getFirstChild () setNodeValue (strPhone);.. modiRestaurant.getElementsByTagName ( "address") item (0. ) .GETFIRSTCHILD (). setNodeValue (straddress); // Call bean Write the corresponding XML file WriteXmlBean.writexml (DOC, "WebApps / Canyin / Data / Restaurants.xm l "); response.sendredirect (Request.GetRequesturi ()); return;} catch (exception e) {}}} // Remove operation IF (Stract.Equals (" DEL ")) {Int Delid; // Record The record to be modified is Item (i) which inti = 0; delid = integer.Parseint (Request.getParameter ("RecordID"). Trim ()); if (Delid == 0) {Out.Print ShowDialog ("You want to modify the restaurant's record does not exist!")); return;} file: // Sign display record exists Boolean Recordexist = false; // Verify data unique for FOR (INT i = 0; i <restaurants . Getlength (); i ) {ELEMENT RESTAURANT = (Element) Restaurants.Item (i); if (Integer.Parseint (Restaurant.getattributeNode ("ID"). getnodeValue ()) ==</p> <p>Delid) {recordexist = true; inti = i;}} if (! recordexist) {Out.print ("You want to delete the record of the restaurant!")); return;} else {// record delete Operation try {node delnode = (node) restaurants.item (inti); doc.getlementsbytagname ("restaurants"). Item (0) .removechild (Delnode); // Call bean WritexmlBean.WriteXml (DOC "WebApps / Canyin / Data / Restaurants.xml"); response.sendredirect (Request.GetRequesturi ()); return;} catch (exception e) {}}}}} // By the external incoming parameter determines the corresponding page corresponding to the page Status if (stract == null) {stroperation = "show";} else {if (stract.equals ("modi")) {stroperation = "modi"; intid = INTEGER.PARSEINT (Request.GetParameter ("RecordID") );} Else {if ("addNew") {stroperation = "addnew";} else {stroperation = "show";}}} // If a empty record, the change page status is "new increase" "If (Restaurants.getLength () == 0) {Stroperation =" addnew ";}%> <html> <head> <title> Oddworld Catering System </ title> <meta http-equiv =" content-type "Content = "text / html; charSet = GB2312"> <meta http-equiv = "expires" content = "0"> <link rel = "stylesheet" href = "../../ incr Ude / itsp.css "type =" text / css "> </ head> <body> <div align =" center "> <table width =" 100% "border =" 0 "cellspacing =" 0 "cellpadding =" 0 "Height =" 22 "> <Tr> <TD Width =" 1 "> <imig src =" ../../ images / top_r1.gif "Width =" 62 "height =" 22 "> </ td > <Td width = 150 align = "center"></p> <p>Dining System Management - Restaurant Management </ TD> <TD> <img src = "../../ images / top_r2.gif" Width = "294" Height = "22"> </ td> <TD Width = 100 align = "center"> <a href="/index.html"> [exit system] </a> </ td> </ tr> </ table> <br> <br> <table bgcolor = "# 999999 "Align = center border = 0 cellpadding = 1 cellspacing = 1 width =" 90% "> <tbody> <tr bgcolor =" # Efefef "align =" center "valign =" middle "> <td class = tttable height = 30 width = "20"> </ td> <td class = tttable height = 30 width = "0"> Restaurant name </ td> <td class = tttable height = 30 width = "0"> Restaurant call </ td > <Td class = tttable height = 30 width = "0"> <div align = "center"> restaurant address </ div> </ td> <td class = tttable height = 30 width = "30"> <div align = "Center"> Modify </ div> </ td> <td class = tttable height = 30 width = "30"> <div align = "center"> Delete </ div> </ td> </ tr> < % For (int i = 0; i <restaurants.getlength (); i ) {Element restaurant = (Element) Restaurants.Item (i); if (Stroperation == "MODI" && integer.Parseint (" ID "). GetNodeValue ()) == Inti d) {%> <% // Display modified format> <tr align = "center" bgcolor = "# fff" valign = "middle"> <form name = dataform action = "<</p> <p>% = Request.getRequesturi ()%>? ACT = Modido "Method =" Post "OnSubmit = '' Return Checkform (this); ''> <TD Class = Tdsmall Height = 25 Width =" 20 "> <input type = "hidden" name = "RecordID" value = "<% = restaurant.getattributenode (" ID "). getnodevalue ()%>> <% = (i 1)%> </ td> <td class = tdsmall Height = 25> <input name = "name" class = step = "=" = ""). Item (0). Item (0) .haschildNodes ()). Item (0) .haschildNodes ()). (0) .haschildNodes ()) { Out.print (Restaurant.GtelementsBytagname ("name"). Item (0) .GetfirstChild (). getnodeValue ());}%> "Maxlength =" 40 "> </ td> <td class = tdsmall height = 25> <Input Name = "Phone" Class = STYL = "Height: 22px; Width: 100px" Value = "<% IF (Restaurant.GtelementsBytagname (" Phone "). Item (0) .haschildNodes ()) {Out.print (Restaurant.GtelementsBytagname ("Phone"). Item (0) .GetfirstChild (). getnodevalue ());}%> "MaxLength =" 20 "> </ td> <TD Class = TdSmall Height = 25> <input name = "address" class = stedit style = "Height: 22px; width: 200px" value = "<% IF (Restaurant.GtelementsBytagname (" address "). Item (0) . HaschildNodes ()) {Out.print (Restaurant.GetElementsBytagname ("Address"</p> <p>) .item (0) .Getfirstchild (). getnodeValue ());}%> "maxlength =" 100 "> </ td> <td class = tdsmall height = 25 width =" 25> <a href = "JavaScript : IF (Checkform () == false; "> <img border = 0 height = 15 src =" ../../ images / editok.gif "width = 15> </a> </ td> <TD Class = tdsmall height = 25 width = "25"> </ td> </ form> </ tr> <%} else {// Displays normal format%> <tr align = "center" bgcolor = "# fffff" Valign = "middle"> <TD class = tdsmall height = 25 width = "20"> <% = (i 1)%> </ td> <td class = tdsmall height = 25 width = "0"> <% IF (Restaurant.GtelementsBytagname ("name"). Item (0) .HaschildNodes ()) {out.print (Restaurant.GetElementsBytagname ("name"). item (0) .GetfirstChild (). getnodeValue ());}% > </ td> <td class = tdsmall height = 25 width = "0"> <% IF (Restaurant.GtelementsBytagname ("Phone"). Item (0). HaschildNodes ()) {Out.print (Restaurant.GtelementsBytagname) "phone"). Item (0) .GetfirstChild (). getnodeValue ());}%> </ td> <td class = tdsmall height = 25 Width = "0"> <% IF ("Address"). Item (0) .HaschildNodes ()) {out.print (Restaurant.Print ("Address"). Item (0) .GetFirstChild () .GetnodeValue ());}%> </ td> <td class = tdsmall height = 25 width = "30"> <a href = "<</p> <p>% = Request.getRequesturi ()%>? ACT = Modi & RecordId = <% = Restaurant.getAttributeNode ("ID"). getnodeValue ()%>> <img border = 0 height = 15 src = "../../ Images / edit.gif "width = 15> </a> </ td> <td class = tdsmall height = 25 width =" 30 "> <img border = 0 height = 15 onclick =" JavaScript: IF (confirm) 'Do you make sure you delete this record, will be guided to the record that cannot be used?' ') {Window.location.href =' '<% = Request.getRequesturi ()%>? ACT = DEL & RECORDID = <% = Restaurant. GetAttributeNode ("ID"). getnodevalue ()%> '';} "src =" ../../ images / delete.gif "style =" cursor: hand "width = 15> </ td> </ tr > <%}}%> <% IF (Stroperation == "AddNew") {// Displays new format%> <tr align = "center" BGColor = "# fff" Valign = "Middle"> <form name = DataForm2 action = "<% = Request.get = addnewdo" Method = "post" onSubmit = '' Return Checkform2 (this); ''> <td class = tdsmall height = 25 width = "20 "> </ td> <td class = tdsmall height = 25> <input name =" name "class = stedit style =" = "" "value =" "MAXLENGTH =" 40 "> </ Td> <td class = tdsmall height = 25> <input name = "phone" class = stedit style = "= step; width: 100px" value = "" MAXLENGTH = "20"</p> <p>> </ Td> <td class = tdsmall height = 25> <input name = "address" class = stedit style = "Height: 22px; width: 200px" value = "" MAXLENGTH = "100"> </ td> < Td class = tdsmall height = 25 width = "25"> <a href="javascript:if (checkform2()==false )"> <img border = 0 height = 15 src = "../../iMages /EDITOK.GIF "width = 15> </a> </ td> <td class = tdsmall height = 25 width =" 25 "> </ td> </ form> </ tr> <%}%> </ TBODY> </ table> <br> <table align = center border = 0 cellpadding = 0 Cellspacing = 2 width = "95%"> <tbody> <tr valign = center> <TD align = middle> <BR> <TABLE Border = 0 cellpadding = 0 cellspacing = 0> <Tr> <TD> <% IF (StrOperation == "AddNew") {%> <input class = stbtm name = update onclick = "javascript: if (Checkform2 () == False); "TYPE = Button value =" Update Record "> <%} else {if (Stroperation ==" MODI ") {%> <input class = stbtm name = update Onclic K = "javascript: if (checkform () == false;" Type = Button value = "Update Record"> <%} else {%> <input class = stbtm type = "button" name = "button" value = "New" onclick =</p> <p>"JavaScript: window.location.href = '' <% = Request.getRequesturi ()%>? ACT = AddNew '';"> <%}}%> </ td> <TD> <input class = stbtm type = "Button" name = "button" value = "returns" onclick = "javascript: window.location.href = '' index.jsp ';"> </ td> </ tr> </ table> </ td > </ Tr> </ table> <p> </ p> </ div> <script language = javaScript> <! - function checkform2 () {var checkblank = / ^ (/ s * | (/) | (/.)) * /; if ("DataForm2.Name.Value) {Alert (" The name of the restaurant cannot be empty! "); dataform2.name.focus (); Return False;} f (CHECKBLORM2.PHONE.VALUE) {Alert ("Restaurant phone can't be empty!"); dataform2.phone.focus (); return false; }window.DataForm2.Submit (); } Function checkform () {var checkblank = / ^ (/ s * | (/) | (/.)) * * (checkblank.test (dataform.name.value) {alert ("Restaurant name cannot be Empty! "); DataForm.name.focus (); Return False; } IF (checkblank.test (dataform.phone.value) {alert ("Restaurant phone can't be empty! "); Dataform.phone.focus (); return false;} Window.DataForm.Submit ();} -> </ script> Description: There are many places in this document, because in the development process of the program Of the excessive concise procedural will often bring the difficulties of later maintenance. Develop experience: Doc.GetElementsBytagname ("Restaurants"). The return value of Item (INT i) is Node type, if not to call its attribute value, there is no need Forced transformation is Element type. It can be done directly. This system uses a forced transformation because of the mistake of the development of reference.</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-41783.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="41783" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.037</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'fL74D6Oj3IQ786TFP4mhURnRLZydLzGeTZChhqeFcZAqDYKd4cj0kPXkIOHXoDNi71fTi5kYok48d1a4V5q1RQ_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>