An example of using JSP + JavaBean + XML

xiaoxiao2021-03-06  86

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 boot file storage folder, only the index.html file is stored

Document brief description: /tomcat/webapps/canyin/data/Users.xml ----- Record user information / Tomcat/webapps/canyin/data/restaurants.xml ----- Record the basic information of the restaurant

/Tomcat/webapps/root/index.html ----- Home, page appears in the page, ask the user to enter your username, password

/tomcat/webapps/canyin/jsp/webapps/canyin/jsp/loginjudge.jsp ----- User identity judgment 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 and other information

/Tomcat/webapps/canyin/web-inf/classes/canyin/eb-inf/classess/canyin/checksessionBean.class ---- Background Management Detection Sign User ID SESSION value, if not 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 Enter XML file

Document details and accompanying code descriptions.

/ Tomcat/webapps/canyin/data/Users.xml

Code:

- Description: Field meaning is the username, password, and user identity / Tomcat/webapps/canyin/data/restaurants.xml code: - - Shanghai Ting fast food restaurant 021-76546726

Broadway Plaza - Shangri-La Hotel 021-2312134
No. 1023 Nanjing Road < / address> Description: property is a total of how many records in the Restaurants.xml file, each new one, no matter whether it is deleted, this value increases 1, just The id item of the automatic increase of 1 in the database. 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></p> <p><body οnlοad = "javascript: dataform.username.focus ()> <div align =" center "> <table width =" 100% "border =" 0 "cellspacing =" 0 "cellpadding =" 0 "Height =" 22 "> <tr> <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 = dataform method = post action = '' canin / jsp / loginjudge.jsp ''> <tr> <td width = "100"> <b > Login Name: </ b> </ td> <td></p> <p><Input Maxlength = 16 Name = "Username" class = step 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 name = Submit OnClick = "javascript: window.location.href = '' index.asp? myjoke = 1 '';" type = button value = "Modify Password"> </ TD> <TD> </ TD> </ TR> </ tbody> </ table> <br> </ td> </ tr> </ table> </ td> </ TR> </ table> </ div> </ body> </ html> <script logage = JavaScript> <! - function checkform () {var checkblank = / ^ (/ s * | (/) | (/.))* </p> <p>IF (CHECKBLANK.TEST (DataForm.username.value) {alert ("The login name cannot be empty!"); return false;} if (checkblank.Test (dataform.userpass.value) {alert ("password cannot be Empty! "); Return False;} WINDOW.DATAFORM.SUBMIT ();</p> <p>} -></p> <p></ Script></p> <p>Description: Submit the user name and user password to /tomcat/webapps/canyin/jsp/loginjudge.jsp/loginjudge.jsp</p> <p>/Tomcat/webapps/canyin/web-inf/classes/canyin/checksessionBean.class (code is the corresponding Java file)</p> <p>Package Canyin;</p> <p>Import javax.servlet.http.httpsession; import javax.servlet.http.httpservletRequest;</p> <p>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.getSession (false); return ( bolCheckPass); if (strSessionName == null || strCheckValue == null) {return (bolCheckPass);}! else {if (session = null && session.getValue (strSessionName)! = null) {bolCheckPass = session.getValue (strSessionName ). Equals (strcheckvalue);} return (bolcheckpass);}}}</p> <p>Description: Check if the value of the session name of the parameters and the value of the parameter incoming fields are equal.</p> <p>/ Tomcat/webapps/canyin/web-inf/classes/canyin/connxmlbean.class</p> <p>Code: package canyin;</p> <p>Import javax.xml.parsers. *; import javax.xml.transform. *; import javax.xml.transform.dom.domsource; import javax.xml.Transform.Stream.StreamResult; import org.w3c.dom. *;</p> <p>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.toString ();} return (strExc);} public Document getXmlDoc () {RETURN (DOC);}} Description: Open a specified XML file</p> <p>/ Tomcat/webapps/canyin/web-inf/classes/canyin/writexmlbean.class</p> <p>Code: package canyin;</p> <p>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. *;</p> <p>public class writeXmlBean {public writeXmlBean () {} public String writeXml (Document doc, String xmlFileName) {String strExc = ""; try {TransformerFactory tfactory = TransformerFactory.newInstance (); Transformer transformer = tfactory.newTransformer ();</p> <p>Domsource Source = New Domsource (DOC);</p> <p>StreamResult Result = New StreamResult (New File (XMLFileName);</p> <p>Transformer.Transform (Source, Result);} catch (exception e) {strexc = E.toString ();} return (strexc);}}</p> <p>Description: Write the contents of the DOM to a specified XML file.</p> <p>/Tomcat/webapps/canyin/jsp/loginjudge.jsp</p> <p>Code: <% - ODDWORLD Catering Management System (Simplified Chinese Version) December 1, 2002 Copy Right By Joard Ast Loginjudge.jsp Function: User Authentication, Different from the user indicated in /Data/User.xml file Identity Decision Transfer 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 =" Canyin. * "%> <jsp: usebean id =" xmlbean "class =" canin.connxmlbean "scope =" page "/></p> <p><% session.setmaxinactiveInterval (1800);</p> <p>Document doc; nodelist users; string strexc = ""; string strusername, strpassword;</p> <p>StruserName = (String) Request.getParameter ("UserName"); strpassword = (string) Request.getParameter ("Userpass);</p> <p>/ / 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> ") Return;}</p> <p>Xmlbean.connxml ("WebApps / Canyin / Data / Users.xml"); DOC = XMLBean.getXmldoc ();</p> <p>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 strAtrPassWordValue = user.getAttributeNode ( "password") getNodeValue ();. String strAtrRoleValue = user.getAttributeNode ( "roles") getNodeValue ();. if (strAtrNameValue.equals (strUsername) && stratrpasswordValue.equals (strpassword)) {IF ("admin")) {Out.Println ("<script language = 'javascript'"); out.println ("Alert ('Welcome management Login system! ''); "); Out.println (" </ script> "); // Setting the session (SESUSERROLE) indicating the user identity, admin SESSION.SetAttribute (" SESUSERROLE "," Admin Admin "); // jump to the management page response.sendredirect (" admin / admin_rest.jsp "); return;} else {// Set the session (SESUSERROLE) indicating the identity of the user, the administrator is User session.setttribute (" " SESUSERROLE "," User "); // Jump to the normal user page response.sendredirect ("index.jsp"); return;}} else {Out.println ("<script language = 'javascript'"); out.println ("Alert) '' Username or password incorrect! '); "); Out.println (" History.go (-1); "); out.println (" </ script> "); return;}</p> <p>}}}} catch (exception e) {strexc = e.tostring ();}%> Description: .......</p> <p>/ Tomcat/webapps/canyin/jsp/admin/admin_Rest.jsp</p> <p>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. -%> <% @ 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 =" canin. * "%></p> <p><% @ include file = "../../ include / sys_dialog.jsp"%></p> <p><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" /></p> <p><% // Check the user identity, judgment is an admin IF (! ChecksessionBean.checksessionBean (Request, "SESUSERROLE", "Admin"))) {Out.print (ShowDialog ("You don't manage the permissions!", " /INDEX.HTML "); Return;}</p> <p>// Get relevant data Document Doc; Nodelist Restaurants from the restaurant data file REST.XML;</p> <p>String strat; int int ID = 0; string stroperation = "show";</p> <p>/ / Accept the external incoming parameter strast = (string) Request.GetParameter ("ACT");</p> <p>Xmlbean.connxml ("WebApps / Canyin / Data / Restaurants.xml"); DOC = Xmlbean.getxmldoc (); restaurants = doc.getlementsBytagname ("Restaurant");</p> <p>/ / Determine the operation IF (Stract! = Null)) {String Strname; String Straddress; TEXT TEXTSEG; STRNAME = (String) Request.getParameter ("name"). Trim (); strphone = (string) Request.getParameter ("Phone"). Trim (); straddress = (string) Request.getParameter ("address). Trim). Trim (); // data check IF (Strname == null) {OUT.PRINT (ShowDialog! "); Return;} if (strphone == null) {Out.print (showdialog "Restaurant phone can't be empty!")); Return;} / * if (straddress == null) {Out.print (ShowDialog ("Restaurant can not be empty!")); Return;} * / // verify Uniqueness for data 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 Dupunt!")); Return;} else {IF ((String) Restaurant.GtelementsBytagname "name"). Item (0) .GetfirstChild (). getnodevalue ()). Equals (strphone)) {Out.print (ShowDialog ("Restaurant Repeat!")); Re Turn;}}} // Get existing recorded number, to set the unique incremented ID attribute int INUM = 0; ELEMENTSEMENTSBYTAGNAME ("Restaurants"). Item = ("restaurants"). Item 0); intNum = integer.parseint ("num"). GetnodeValue ()); intNum = 1; // Add 1 RESTNUM.GETATTRIBUTEENODE ("NUM"). Setnodevalue (String). SetnodeValue .valueof (intNum);</p> <p>// Add 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 = 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);. // Call the bean to write the corresponding XML file WriteXmlBean.WriteXML (DOC, "WebApps / Canyin / Data / Restaurants.xml");</p> <p>response.sendRedirect (request.getRequestURI ()); return;} if (strAct.equals ( "modiDo")) {String strName; String strPhone; String strAddress; Text textseg; int modiId; // record to be modified is recorded item (i) which int INTI = 0; strname = (string) Request.getParameter ("name"). Trim (); strphone = (string) Request.getParameter ("phone"). Trim (); straddress = (String) Request.getParameter ("address"). Trim (); MODIID = INTEGER.PARSEINT ("RECORDID"). Trim ()); // Data Check IF (Strname == Null) {OUT .print (ShowDialog! ")); return;} if (strphone == null) {Out.print (ShowDialog (" Restitute phone can't be empty! ")); Return;} if (MODIID) == 0) {OUT.PRINT ("You want to modify the restaurant's record does not exist!")); Return;} / * if (straddress == null) {Out.print ("ShowDialog (" Restiating ! ")); Return;} * / / / flag display records There is boolean recordexist = false; // check data unique for (int i = 0; i <restaurants.getLength (); i ) {ELEMENT RESTAURANT = (ELEMENT) RESTAURANTS.ITEM (I); IF (Integer.Parseint (Restaurant.GetaTributenode ("ID"). GetnodeValue ()) == MODIID) {Recordex IST = true; inti = i;</p> <p>} If (((String) restaurant.getElementsByTagName ( "name"). Item (0) .getFirstChild (). GetNodeValue ()). Equals (strName) && Integer.parseInt (restaurant.getAttributeNode ( "id"). GetNodeValue ( ))))! = modiid) {Out.print (ShowDialog ("Restaurant Name Repeat!")); Return;} else {ife ((String) Restaurant.GtelementsBytagname ("name"). item (0) .GetfirstChild () .GETNODEVALUE ()). Equals (strphone) && integer.parseint (Restaurant "). getnodeValue ())! = modiid) {Out.print (ShowDialog (" Resting Telephone Repeat! ")); Return; }}} If (! Recordexist) {out.print ("You want to modify the restaurant's record does not exist!"); Return;} Else {// Recording changes Try {Element ModireStaurant = (Element) Restaurants .item (intI);. modiRestaurant.getElementsByTagName ( "name") item (0) .getFirstChild () setNodeValue (strName);... modiRestaurant.getElementsByTagName ( "phone") item (0) .getFirstChild () setNodeValue (strPhone ModiRestaurant.getlements. Item (0) .GetfirstChild (). SetNodeValue (straddress); // Call bean WriteXmlbe Writexmlbe An.writexml (DOC, "WebApps.xml"); response.sendredirect (Request.GetRequesturi ()); return;} catch (exception e) {}}} // Removal operation IF (Stract) .Equals ("del")) {int Delid; // Record to modify the record is Item (i) which INTI = 0;</p> <p>Delid = Integer.Parseint (Request.getParameter ("RECORDID"). Trim ());</p> <p>IF (Delid == 0) {Out.print ("You want to modify the restaurant's record does not exist!")); return;} file: // Sign display record exists boilean recording existing boolean recording</p> <p>/ / Uniqueness for check data for (int i = 0; i <restaurants.getLength (); i ) {Element restaurant = (Element) Restaurants.Item (i); if (Integer.Parseint (Restaurant.GetaTRibutenode ID "). GetNodeValue ()) == Delid) {recordexist = true; inti = i;}} if (! recordexist) {Out.print (" You want to delete a restaurant's record does not exist! "); return }} Else {// Operation of Recording Delete Try {node delNode = (Node) Restaurants.Item (inti); doc.getlementsbytagname ("restaurants"). Item (0) .removechild (Delnode);</p> <p>// Call the bean to write the corresponding XML file WriteXmlBean.WriteXML (DOC, "WebApps / Canyin / Data / Restaurants.xml");</p> <p>Response.sendRedirect (Request.getRequesturi ()); Return;} catch (exception e) {}}}</p> <p>}</p> <p>// By the external incoming parameter decision page corresponding processing status IF (strope = ";} else {if (stract.equals (" modi ") {stroperation =" modi "; intid = Integer.Parseint ("RECORDID");} else {if ("addNew") {stroperation = "addnew";} else {stroperation = "show";}}}</p> <p>// If a empty record, the change page status is "new" IF (restaurants.getlength () == 0) {stroperation = "addnew";}%></p> <p><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 = "../../ include / itsp.css" type = "text / css"> </ head></p> <p><body> <div align = "center"> <table width = "100%" border = "0" cellspacing = "0" cellpadding = "0" height = "22"> <tr> <td width = "1" > <img src = ".. -" Width = "62" Height = "22"> </ td> <td width = 150 align = "center"> Catering System Management - Restaurant Manage </ 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 phone </ 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"> modification </ div> </ td> <td class = tttable height = 30 width = "30"> <div align = "center "> Delete </ div> </ td> </ tr> <% for (int i = 0; i <</p> <p>Restaurants.getlength (); i ) {Element restaurant = (Element) Restaurants.Item (i); if (Stroperation == "MODI" && integer.parseint ("ID"). getnodeValue ()) == INTID) {%> <% // Display modified format> <tr align = "center" BGColor = "# fff" Valign = "middle"> <form name = dataform action = "<% = 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 = stedit style = "HEIGHT: 22px; WIDTH: 150px" value = "<% if (restaurant.getElementsByTagName (". name ") item (0) .hasChildNodes ()) {out.print (restaurant.getElementsByTagName ("name"). Item (0) .Getfirstchild (). getnodeValue ());}%> "MaxLength =" 40 "> </ td> <td class = tdsmall height = 25> <input name =" phone "class = stedit style = "HEIGHT: 22px; WIDTH: 100px" value = "<% if (restaurant.getElementsByTagName (" phone ".) item (0) .hasChildNodes ()) {out.print (restaurant.getElementsByTagName (" phone ") .Item (0) .GetfirstChild (). getnodevalue ());}%>" maxlength = "20"</p> <p>> </ 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.GtelementsBytagname ("address"). 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 {// Display normal format> <tr align = "center" bgcolor = "# fff" Valign = "middle"> <td class = tdsmall height = 25 width = "20"> <% = (i 1) %> </ td> <td class = tdsmall height = 25 width = "0"> <% IF (Restaurant.GetelementsBytagname ("name"). item (0) .haschildNodes ()) {out.print (Restaurant.GetElementsBytagname ("Name"). Item (0) .Getfirs TCHILD (). 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> <</p> <p>td class = tdsmall height = 25 width = "0"> <% if (restaurant.getElementsByTagName ( "address"). item (0) .hasChildNodes ()) {out.print (restaurant.getElementsByTagName ( "address"). item (0) .Getfirstchild (). GetNodeValue ());}%> </ td> <td class = tdsmall height = 25 width = "30"> <a href="<%=Request.getRequesturi() now? 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 to delete this record, after deletion Will be guided to records? '')) {Window.location.href = '' <% = Request.get = del & RecordId = <% = restaurant.getattributenode ("ID"). GetnodeValue () %> '';} "Src =" ../../ images / delete.gif "style =" cursor: hand "width = 15> </ td> </ TR> <%}}%> <% IF (Stroperation == "addNew") {// Display new format%> <tr align = "center" bgcolor = "# fff" valign = "middle"> <form name = dataform2 AC Tion = "<% = Request.get = addNewdo" Method = "post" onSubmit = '' Return Checkform2 (this); ''> <TD class = tdsmall height = 25 width = "20"> </ td> <td class = tdsmall height = 25> <</p> <p>Input name = "name" class = stedit style = "Height: 22px; width: 150px" value = "" MAXLENGTH = "40"> </ td> <TD class = tdsmall height = 25> <input name = "phone" Class = stedit style = "Height: 22px; width: 100px" value = "" MAXLENGTH = "20"> </ td> <TD class = tdsmall height = 25> <input name = "class = step =" 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 (Stroperatio n == "addnew") {%> <input class = stbtm name = update onclick = "javascript: if (checkform2 () == false);" TYPE = Button value = "Update Record"> <</p> <p>%} else {if (Stroperation == "MODI") {%> <input class = stbtm name = update onclick = "JavaScript: if (checkform () == false;" Type = Button value = "Update Record"> <%} Else {%> <input class = stbtm type = "button" name = "button" value = "new" onclick = "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> < / body> </ html> <script language = javascript> <! - function checkform2 () {var checkblank = / ^ (/ s * | (/) | (/.)) * * * (/.)) * * (/.)) * (checkblank.test (DataForm2.Name.Value)) {Alert ("Restaurant Name cannot be empty!"); dataform2.name.focus (); return false;} if (checkblank.test (dataform2.phone.value) { Alert ("Restaurant phone can't be empty! "); Dataform2.phone.focus (); return false; }window.DataForm2.Submit ();} function checkform () {var checkblank = / ^ (/.) | (/ .)) * $ /; If (checkblank.test (dataform.name.value) {alert ("The name of the restaurant cannot be empty!"); Dataform.name.focus (); return false;</p> <p>} IF (CHECKBLORM.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. It is not concise, because in the development of the program, excessive concise procedures often bring the difficulties of later maintenance.</p> <p>Development experience:</p> <p>Doc.getElementSbyTagName ("Restaurant"). The return value of Item (INT i) is an Node type. If it is not to call its attribute value, it is not necessary to force the transformation into the Element. Can be operated directly. This system uses a mandatory transformation because of the mistake of the resilience of the reference. It can be considered in the future to consider using NODE directly to operate.</p> <p>Trim () and interger.parseint () functions can not accept NULL type values</p> <p>The files under Tomcat are all in the directory from Tomcat, see /Webapps/canyin/jsp/Userjudge.jsp on the XML path.</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-123826.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="123826" 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.042</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 = 'v_2FRu1geDwmhOpvByvXdAiBlDffHKvVWd5qgym84wtxNE2uCUMudZCsj1EcUizcItJNXfEMoM_2BC5k0zX7'; 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>