51. Write content to the file <%@ page import= "java.io.*"%> <% String str = "Print Me"; Always give the path from root.
This is way it almost always works.
String nameoftextfile = "/usr/anil/imp.txt";
try {printwriter pw = new PrintWriter (new FileOutputStream (Nameoftextfile));
Pw.println (str);
Clean up pw.close ();
catch (IOException e) {out.println (E.getmessage ()); %> 52. First read the file and then write the file <%@ page language = "java"%> <%@ page contentType = "text/html; charset=gb2312 "%> <%@ page import =" java.util.* "%> <%@ page import =" java.lang.* "%> <%@ page import = "javax.servlet.*"%> <%@ page import = "javax.servlet.jsp.*"%> <%@ page import = "javax.servlet.http.*"%> &
lt;%@ page import= "java.io.*"%> eryrytry <% int count=0;
FileInputStream fi =new fileinputstream ("Count.txt");
ObjectInputStream si= New ObjectInputStream (FI);
Count =si.readint ();
count++;
Out.print (count);
Si.close (); FileOutputStream fo =new fileoutputstream ("Count.txt");
ObjectOutputStream so= new ObjectOutputStream (FO);
So.writeint (count);
So.close (); %> 53. Line type input frame <input name=password size=10 type=password style= "border-left-width:0;
border-right-width:0; border-top-width:0; Border-bottom-style:solid; Border-bottom-width:1; Background-color: #9CEB9C "> 54. You can change the background to a button character by changing the properties of the CSS <td width= align=" center "bgcolor=" #E0E0E0 "
Onmouseover=this.classname= ' MOUSEOVERBT '; Onmouseout=this.classname= ' mouseout '; ><a href= "tm.asp?classid=76" ><font color= "#000000" > Recorder pen </ Font></a></td> <style> MOUSEOVERBT {background-image:url (http://www.yongle.com.cn/img/
Btbgw64h20y.gif);
Background-repeat:no-repeat; }. mouseout {background-color: #E0E0E0} </style> 55. Press the CTRL and Q keys at the same time document.onkeydown=function () {if (Event.ctrlke y&&event.keycode==81) {alert (1)}}//56. The following is a complete display of hint code, the idea is when the mouse stop is the contents of the div displayed in the mouse out, when the mouse moved out after the Div hidden away------- --------------------------------------------------------------------------------------------------------------<!
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" > <HTML> <style> #hint {width:198px;
border:1px solid #000000;
Background: #99ff33;
Position:absolute;
Z-index:9;
padding:6px;
line-height:17px;
Text-align:left;
top:1520px; } </style> <script language= "JavaScript" > <!--function showme () {var oson=
WINDOW.DOCUMENT.GETELEMENTBYID ("hint");
if (oson==null) return;
With (Oson) {innertext=guoguo.value;
style.display= "Block";
style.pixelleft=window.event.clientx+window.document.body.scrollleft+6;
style.pixeltop=window.event.clienty+window.document.body.scrolltop+9;
} function Hidme () {var Oson=window.document.getelementbyid ("hint");
if (oson==null) return;
Oson.style.display= "None"; //--> </SCRIPT> <BODY> <text id=guoguo value=ga> <a href=# onmouseover=showme () onmouseout= Hidme () onmousemove=showme () Son=hint>dfdfd</a> <div id=hint style= "Display:none" ></div> </BODY> </HTML>---------------------------------- -----------------------------------------------------------------------------------57. Pop-up Window Method one: <body onload= " Openwen () > Browser pop-up window when reading the page; method two: <body onunload= "Openwen ()" > Browser pop-up window when leaving the page; Method three: Calling with a connection: <a href= "#" onclick= "
Openwin () > Open a window </a> Note: the "#" used is a virtual connection. Method Four: Call with a button: <input type= "button" onclick= "Openwin ()" value= "open Window" > When to load script 58. Dynamically changing font size function dozoom (size
) {document.getElementById (' Zoom '). style.fontsize=size+ ' px '} function aa () {var newwin=window.open (URL);
newwin.document.form1.text1.value=value1;
Change the property opener.document.form2.text2.value=value2 of the field on the pop-up window; Change the value of the domain of the parent window 59. Determine what browser var name = Navigator.appname;
if (name = = "Microsoft Internet Explorer") alert ("IE"); else if (name = = "Netscape") alert ("NS");//60.vbsscript OK box <script language= "VBScript" > <!--MsgBox "OK delete." ", 4//--> </script>//61. Copy content to cutboard function jm_cc (BB) {var ob=eval ("Document.form1.")
+BB);
Ob.select ();
Js=ob.createtextrange ();
Js.execcommand ("Copy");
}//62.java establishes a database connection to fetch the data public void init () {String url= "jdbc:odbc:javadata";
try {class.forname ("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=drivermanager.getconnection (URL, "sa", "");//mssql database user sa and password DatabaseMetaData dma=con
. GetMetaData ();
System.out.println ("Connect to" +dma.geturl ());
System.out.println (";D River" +dma.getdrivername ()); System.out.println (";
Version "+dma.getdriverversion ());
System.out.println ("");
Statement stmt=con.createstatement ();
ResultSet rs=stmt.executequery ("select * from Company.dbo.TB_NAME where number=1");//sql Rs.next ();
String dispresult=rs.getstring ("name");
System.out.println (Dispresult);//instead,you can display it in Paint () or use AWT etc.
Rs.close ();
Stmt.close ();
Con.close (); The catch (SQLException ex) {SYSTEM.OUT.PRINTLN ("!!!
SQL Exception!!! "); WhilE (ex!=null) {System.out.println ("SQLState:" +ex.getsqlstate ());
SYSTEM.OUT.PRINTLN ("Message:" +ex.getmessage ());
System.out.println ("Vendor:" +ex.geterrorcode ());
Ex=ex.getnextexception ();
System.out.println ("");
} catch (Java.lang.Exception ex) {ex.printstacktrace (); }//63. Minimize Window Window.blur ()//64. The path document.
url//65. Periodic execution of a procedure settimeout ("Change_color ()", 600);
66. Set as Home page function Makehome () {Netscape.security.PrivilegeManager.enablePrivilege ("universalpreferenceswrite");
Navigator.preference ("Browser.startup.homepage", location.href); }//67. Set to Collection function Addfav () {if (IE) window.external.AddFavorite (location.href, ' WWW.
OGRISH.COM:GROTESQUE MOVIES and PICTURES ');
if (NS) alert ("For the Bookmark!\n\nnetscape users click OK then press ctrl-d"); }//68. To determine whether a cookie is available navigator.cookieenabled;//69. Displays a modal pop-up window function Setbgcolor_onclick () {var color = Showmodald
Ialog ("/mailpage/compose/colorsel.html", 0, "help=0"); if (color!= null) {document.compose.bgcolor.value = color;
}//70. Two-bit var a=3454545.4454545 after the decimal point is intercepted;
Alert (a.tofixed (2));//71. Prohibit the selection of text on the page to copy <script> function Noeffect () {with (event) {returnvalue = false;
Cancelbubble = true;
} return; } </script> <body onselectstart= "Noeffect ()" oncontextmenu= "Noeffect ()" >//72. Right button menu oncontextmenu= " Event.returnvalue = false "//73. Event prohibition of blistering event.cancelbubble = true//74. Disable input input in the entry box <input style=" ime-mode:disabled "&G
t;//75. Screen Chinese characters and spaces <input name= "txt" ><input type= "submit" onclick= "Alert (!/[^-}]|\s/.test (txt.value))" >//
76. Use JavaScript to determine whether the file Exists function Exists (filespec) {if (filespec) {var fso;
FSO = new ActiveXObject ("Scripting.FileSystemObject"); Alert (FSO.
FileExists (filespec)); Select Picture <input type=file name=f1><p> <input type= "Submit" onclick= "Exists (f1.value)" >//77. Gets the text that is selected by the current text box <input onmouseup= "alert (Document.selection.createRange (). Text)" value=123>//78. Jump to MeshMark the page and not return <a href= "Javascript:location.replace (' http://www.sohu.com/')" >sohu.com</a>//79. Gets the current row is the first few rows of the table <script> function GetRow (obj) {if (event.srcelement.tagname== "TD") {Currow=event.srcelement.pare
Ntelement;
Alert ("This is the first" + (currow.rowindex+1) + "line"); } </script> <table border= "1" width= "100%" Onclick=getrow (this) > <tr> <td width= "20%" > &L t;/td> <td width= "20%" > </td> <td width= "20%" > </td> <td width= "20%" > </td > <td width= "20%" > </td> </tr> <tr> <td width= "20%" > </td> <td w Idth= "20%" > </td> <td width= "20%" > </td> <td width= "20%" > </td> <td width=
"20%" > </td> </tr> </table>//80. Deletes a row of a table, XX indicates a row, subscript starts from 0 to calculate Document.all.myTable.deleteRow (XX)/ 81. Dynamically add rows to the table <table id= "T1" border= "1" > </table> <script language= "JavaScript" > function adD () {T1.insertrow (). InsertCell (). InnerHTML = ' <input name= ' test ' +t1.rows.length+ ' ' > '; //