Dream of life to the public information system

  Abstract: Information System dream of life 

  </ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> <table width = "100%" border = "0" cellspacing = "0" cellpadding = " 0 "> <tr> <td width="185" height="86" align="center" valign="top"> </ td> <td width="499" valign="top"> 

  ************************************************** ****************** 
  * Information System dream of life [DreamTimeNews] 
*
  * Copyright: Dreaming Days 
  * CopyRight :2006-2007 DreamTime All Rights Reserved 
*
  * Program by: [dream of life] 
  * Email: fanwsp@126.com 
  * QQ: 122142023 
  * HomePage: http://wsp.hniuca.net 
*
  * Solemnly declared: the program only to the individual user free use 
  * Without her consent for commercial use is prohibited! 
*
  * This procedure replication and dissemination of personal welcome, but please ensure that the integrity of the proceedings, 
  * Including all the relevant documents. 
  * Procedures author dreams of life [DreamTime] All rights reserved 
*
  ************************************************** ****************** 

  A description of the procedures: 

  Welcome to the dream of life to the public information system. 

  Procedures based on JSP + JavaBean development, the database can use Access, MySql, MSSQL, Oracle database. 
  Development platform: Win2003 + + Apache2.0.52 Mod_jk Tomcat5.54 + 1.2.6 + JDK1.5 
  Normal procedures required for the operation of JVM (Java Virtual Machine) 1.5 or later. 

  Installation Instructions: 

  1, first of all, to build its own JSP server.    Individual operation or integration with the Apache will do (I use the Apache Tomcat +) copy of the procedures to your server's root directory, I used Tomcat, the default path: Tomcat installation directory / webapps / directory.    Make sure the directory called news system, if the system changes the directory name, the system comes with news picture will be displayed.    If you are prepared to empty the data, you can change the directory you want, please according to practical situation. 

  </ Td> </ tr> </ table> 

  Second, database options: 

  1, if you choose Access database, open the WEB-INF \ classes \ DBConfig.property document, modify DBType value of 0 (ie DBType = 0; This is the default value), and amend the Access database path. 

  2, MySql database if they choose, to please themselves with MySql, and download MYSQL the JDBC driver to configure. 
  + MYSQL good debugging JSP server. 
  Then enter the information system's directory. 
  In mysql prompt implementation: \. DreamNews_MySql.sql. 
  DBType revise the value of, and set your use of drivers. 

  3, if you select the SQL Server database, then you installed SQL Server (at the time of installation Please select mixed mode authentication), 
  Then download the SQL Server JDBC driver to configure. 
  Win2003 Server attention to the installation SQLServer2000 to install patches sp3. 
  + Good JSP debugging SQL Server servers. 
  In the enforcement of sql query analyzer / SQL DreamNews_SQL.sql this angle this can be. 
  DBType revise the value of 2, and set your use of drivers. 

  4, if the use of the Oracle database, Members to resolve. 

  5, Note: Selecting a database must be set correctly corresponding database-driven procedure, if not, please do not change the system 
  The default value. 

  6, please do not change the program directory of news, otherwise the process may not be able to show that picture. 

  Because of the time, I only on the Windows platform under test Tomcat, Resin tested.    Procedures to normal operation. 
  Integration with Apache and IIS software can also above normal operation.    On the Linux operating under, please you to debug, 
  Please send any comments to fanwsp@126.com.    I am not grateful.    I am sure that the future will be tested in the Linux platform. 

  Because of personal effort and time, the information system will inevitably there are many shortcomings, welcome to all of you experts correction. 

  Third, procedures directory structure 
  |——-|—————————————– ———- 
  | - Admin | Manage directory 
  |——-|—————————————– ———- 
  |——-|– Css background CSS file directory 
  |——-|—————————————– ———- 
  |——-|– Help backstage help system directory 
  |——-|—————————————– ———- 
  |——-|– Images background picture catalogue 
  |——-|—————————————– ———- 
  |——-|– Js directory of the paper used JS 
  |——-|—————————————– ———- 
  Add |——-|– AddNews.jsp News 
  |——-|– Admin_Class.jsp category management 
  |——-|– Admin_Config.jsp system parameter settings 
  |——-|– Admin_Info.jsp system set up basic information 
  |——-|– Admin_Left.jsp frame of the left navigation pages 
  |——-|– Admin_Main.jsp main framework pages 
  |——-|– Admin_Special.jsp management topic 
  |——-|– Admin_User.jsp User Management 
  |——-|– DelNews.jsp delete News 
  |——-|– Img.htm upload picture pages 
  |——-|– Index.jsp background listing 
  |——-|– Index_Face.html framework of the right pages 
  |——-|– ListNews.jsp Manage News Pages 
  |——-|– Logout.jsp withdraw from the system pages 
  |——-|– Modifynews.jsp amend News 
  |——-|– Person.jsp administrator personal information pages 
  |——-|– Session.jsp judge whether Trent Login 
  |——-|– VerifyCode.jsp code pages 
  |——-|—————————————– ———- 
  | - Buttonimage eWebEditor editor tool catalogue 
  |——-|—————————————– ———- 
  | - Css CSS file directory 
  |——-|—————————————– ———- 
  |——-|– CoolBlue eWebEditor editor use CSS document 
  |——-|—————————————– ———- 
  |——-|– Newscss prospects of the system used by CSS document 
  |——-|—————————————– ———- 
  | - Editor dialog eWebEditor Pages directory pop-up window 
  |——-|– Images catalogue 
  |——-|—————————————– ———- 
  | - Include eWebEditor editor directory contains documents 
  |——-|—————————————– ———- 
  | - Pic of the system catalogue 
  |——-|—————————————– ———- 
  | - Sql database of the system using the angle of this document 
  |——-|—————————————– ———- 
  | - Sysimge eWebEditor editing system catalogue 
  |——-|—————————————– ———- 
  | - UploadFile upload pictures stored directory 
  |——-|—————————————– ———- 
  | - WEB-INF 
  |——-|—————————————– ———- 
  |——-|– Lib jar package store directory 
  |——-|—————————————– ———- 
  |——-|——-|–|– Dom4j.jar eWebEditor editor own class 
  |——-|——-|–|– DreamNews.jar the system used by the type of document 
  |——-|——-|–|– MYSQL-Driver.jar attached to the system MYSQL Driver 
  |——-|——-|–|– Oracle-Driver.jar the system with the Oracle Driver 
  |——-|——-|–|– MSSQL-Driver.jar fringe of the system of SQL Server Driver 
  |——-|—————————————– ———- 
  |——-|– Classes of document directory 
  |——-|—————————————– ———- 
  |——-|——-|– Src JavaBean source directory 
  |——-|——-|——————————— ———- 
  |——-|——-|–|– AdminClass.java type of source document management 
  |——-|——-|–|– Config.java system settings of source files 
  |——-|——-|–|– DBConnection.java of source document database connection 
  |——-|——-|–|– Function.java common method definition of source files 
  |——-|——-|–|– ListClass.java prospects categories of source files show 
  |——-|——-|–|– Log.java log of source files 
  |——-|——-|–|– Login.java user categories source files 
  |——-|——-|–|– MD5.java MD5 encryption algorithm source files 
  |——-|——-|–|– News.java news source document management category 
  |——-|——-|–|– ShowNews.java news show that the source of documents 
  |——-|——-|–|– User.java users of source document management 
  |——-|——-|–|– VerifyCode.java verification of the source code files 
  |——-|—————————————– ———- 
  |——-|——-|– DBConfig.property database configuration file 
  |——-|—————————————– ———- 
  |——-|– Button.xml eWebEditor pattern definition file editor 
  |——-|– DreamNews.mdb Access database 
  |——-|– Style.xml eWebEditor pattern definition file editor 
  |——-|– Web.xml configuration page applications 
  |——-|—————————————– ———- 
  | - Config. Jsp pages of the system configuration 
  | - EWebEditor. Jsp eWebEditor editor of Home 
  | - Index. Jsp Home of the system 
  | - ReadClass. Jsp major categories showed that the system pages 
  | - ReadSClass. Jsp pages of the system shows that subcategory 
  | - Search. Jsp pages of the system News Search 
  | - Special. Jsp pages display feature of the system 
  | - Top. Head of the system of public jsp pages 
  | - Upload. Jsp eWebEditor file upload pages editor 
  | - Note. Txt file this note 
  |————————————————- ———– 

  By DreamTime 2006.3.24 

  ************* Special thanks to [clouds floating by Arrow] ************ 

  Manage: 
  Address: admin / index.jsp must enter the file name index.jsp, or can not sign. 
  Username: admin 
  Password: admin 

  </ Td> </ tr> <tr> 

  ↑ Back 

Jsp used for direct download files function

  Abstract: The realization of direct download files jsp function 

  </ Td> </ tr> <tr> <td width="552" height="35" valign="top" class="ArticleTeitle"> <% 
  / / Sometimes a user wants to download files, but this type of file in the system associated with the browser, the results will become open in IE. 
  / / A common word, excel, such as pdf.    Therefore the documents translated into data flow to its browser does not know the type of document to download purposes. 
  / / Usage: 
  / / Download image 

  String root = getServletContext (). GetRealPath ("/"); 
  String path = request.getParameter ( "path"); 
  String name = request.getParameter ( "name"); 

  Response.setContentType ( "unknown"); 
  Response.addHeader ( "Content-Disposition", "filename = \" "+ name +" \ ""); 

  Try 
  ( 
  Java.io.OutputStream os = response.getOutputStream (); 
  Java.io.FileInputStream fis = new java.io.FileInputStream (root path + + name); 

  Byte [] b = new byte [1024]; 
  Int i = 0; 

  While ((i = fis.read (b))> 0) 
  ( 
  Os.write (b, 0, i); 
  ) 

  Fis.close (); 
  Os.flush (); 
  Os.close (); 
  ) 
  Catch (Exception e) 
  ( 
  ) 
  %> </ Td> <td width="175" valign="top" class="ArticleTeitle"> 
  </ Td> </ tr> <tr> <td height="25" colspan="2" valign="top" class="ArticleTeitle"> 

  ↑ Back 

Done with a calendar marking

  Abstract: A marker used to do calendar 

  </ Td> </ tr> <tr> <td width="531" height="35" valign="top" class="ArticleTeitle"> This is what I learn from a 1.0 jDlog practice.    Dlog.tld look at the document: 

  <? Xml version = "1.0" encoding = "GB2312?"> 
  Taglib PUBLIC "- / / Sun Microsystems, Inc / / DTD JSP Tag Library 1.1 / / EN" 

  "Http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd"> 

1.0
1.1
  Dlog 
  Http://www.dlogcn.com 


  Calendar 
  Jdlog.tags.CalendarTag 
  <bodycontent> Empty </ body> 


  Year 
  False 
  True 


  Month 
  False 
  True 




  CalendarTag.java again, and from the property, or request access to parameters 
  / * 
  * Created on 2004-2-6 
  * / 
  Package jdlog.tags; 

  Import java.text.SimpleDateFormat; 
  Import java.util.Calendar; 
  Import java.util.Locale; 

  Import javax.servlet.http.HttpServletRequest; 
  Import javax.servlet.jsp .*; 
  Import javax.servlet.jsp.tagext .*; 

  / ** 
  * @ Author Liudong 
  * Tag library calendar 
  * / 
  Public class CalendarTag extends TagSupport ( 

  Protected int year = 2005; 
  Protected int month = 2; 

  Private final static SimpleDateFormat sdf = 
  New SimpleDateFormat ( "MMMMM yyyy" Locale.ENGLISH); 

  Public int doStartTag () (throws JspException 
  Calendar cal = Calendar.getInstance (); 

  PageContext.getOut JspWriter out = (); 
  Try ( 

  If (pageContext.getRequest (). GetParameter ( "paramYear")! = Null) ( 

  Year = Integer.parseInt (pageContext.getRequest (). GetParameter ( "paramYear"));) 

  If (year> 0) 
  Cal.set (Calendar.YEAR, year); 
  ) Catch (Exception e) (System.out.println (e.toString ());} 
  Try ( 
  If (pageContext.getRequest (). GetParameter ( "paramMonth")! = Null) ( 
  Month = 
  Integer.parseInt (pageContext.getRequest (). GetParameter ( "paramMonth"));) 
  If (month> 0 & & month <13) 
  Cal.set (Calendar.MONTH, month-1); 
  Else if (month == 0) ( 
  Cal.set (Calendar.MONTH, 11); 
  Cal.add (Calendar.YEAR, -1); 
  ) 
  Else if (month == 13) ( 
  Cal.set (Calendar.MONTH, 0); 
  Cal.add (Calendar.YEAR, 1); 
  ) 
  ) Catch (Exception e) () 

  Int [] [] = buildCalendar datas (cal); 
  Try ( 

  Out.print ( "<table border = Ɔ 'width =% Sou' align = 'center' cellspacing = Ƈ ' 


  Cellpadding = Ƈ '> <tr> <td colspan=ƍ'> "+ year +" "+ month +" on </ td> </ tr> <tr> <td 


  Class = 'week'> Su </ td> <td class='week'> M </ td> <td class='week'> Tu </ td> 
  <td Class='week'> W </ td> <td 


  Class = 'week'> Th </ td> <td class='week'> F </ td> <td class='week'> Sa </ td> </ tr> "); 
  For (int i = 0; i    Out.print ( "<tr>"); 
  For (int j = 0; j    Out.print ( "<td>" + datas [i] [j ]+"</ td> "); 
  Out.print ( "</ tr>"); 

  ) 
  Out.print ( "</ table>"); 
  ) 
  Catch (Exception e) ( 
  System.out.println ( "Error"); 
  ) 
  / / PageContext.setAttribute (datasId, datas); 

  PageContext.setAttribute ( "year", new Integer (cal.get (Calendar.YEAR))); 
  PageContext.setAttribute (the "month", new Integer (cal.get (Calendar.MONTH) +1)); 

  / / PageContext.setAttribute (titleId, sdf.format (cal.getTime ())); 



  Return SKIP_BODY; 
  ) 
  / ** 
  * Constructors calendar 
  * @ Param year 
  * @ Param month 
  * @ Return 
  * / 
  Protected static int [] [] buildCalendar (Calendar cal) ( 
  Cal.set (Calendar.DAY_OF_MONTH, 1); 
  Int firstDateInWeek = cal.get (Calendar.DAY_OF_WEEK) -1; 
  Int dateOfMonth = getMonthDateCount (cal); 
  Int base + = dateOfMonth firstDateInWeek; 
  Int row = base / 7; 
  Row + = ((base% 7)> 0)? 1:0; 
  Int [] [] cals = new int [row] [7]; 
  Int iCol = firstDateInWeek, iRow = 0; 
  For (int i = 1; i <= dateOfMonth; i + +) ( 
  Cals [iCol iRow] [] = i; 
  If (iCol == 6) ( 
  ICol = 0; 
  IRow + +; 
  ) 
  Else 
  ICol + +; 
  ) 
  Return cals; 
  ) 
  / ** 
  * Designated by the number of days in 
  * @ Param cal 
  * @ Return 
  * / 
  Protected static int getMonthDateCount (Calendar cal) ( 
  Calendar cal2 = (Calendar) cal.clone (); 
  Cal2.add (Calendar.MONTH, 1); 
  Cal2.set (Calendar.DAY_OF_MONTH, 1); 
  Cal2.add (Calendar.DAY_OF_MONTH, -1); 
  Return cal2.get (Calendar.DAY_OF_MONTH); 
  ) 

  Public static void main (String [] args) throws Exception ( 
  Int [] [] = buildCalendar days (Calendar.getInstance ()); 
  For (int i = 0; i    For (int j = 0; j    System.out.print (days [i] [j] + ""); 
  System.out.println (); 
  ) 
  ) 


  / ** 
  * @ Return 
  * / 
  Public int getMonth () ( 
  Return month; 
  ) 

  Public int getYear () ( 
  Return year; 
  ) 


  Public void setMonth (int month) ( 
  This.month = month; 
  ) 


  Public void setYear (int year) ( 
  This.year = year; 
  ) 


  ) 

  Third, call jsp 
  <% @ Page language = "java" contentType = "text / html; GBK charset ="%> 

  <% @ Taglib prefix = "c" uri = "http://java.sun.com/jstl/core"%> 
  <% @ Taglib uri = "/ WEB-INF/dlog.tld" prefix = "dlog"%> 
  <table> <tr> <td Width="200"> 
  </ Td> </ tr> </ table> 

<%
  Integer year = (Integer) pageContext.getAttribute ( "year"); 
  Integer month = (Integer) pageContext.getAttribute (the "month"); 
  Int nextYear = year.intValue (); 
  Int lastYear = year.intValue (); 
  Int next_m month.intValue = () +1; 
  If (next_m> 12) ( 
  Next_m = 1; 
  NextYear + +; 
  ) 
  Int last_m month.intValue = () -1; 
  If (last_m <1) ( 
  Last_m = 12; 
  LastYear -; 
  ) 
%>

  & ParamMonth = <= last_m%%>> on January 
  & ParamMonth = <= next_m%%>> Next Month 
  = & ParamMonth 
  <% = Month.intValue ()%>> last year 
  = & ParamMonth 
  <% = Month.intValue ()%>> next year 

  Function TempSave (ElementID) (CommentsPersistDiv.setAttribute ( "CommentContent" document.getElementById (ElementID). Value); CommentsPersistDiv.save ( "CommentXMLStore");) function Restore (ElementID) (CommentsPersistDiv.load ( "CommentXMLStore"); document . getElementById (ElementID). CommentsPersistDiv.getAttribute value = ( "CommentContent");) </ td> <td width="176" valign="top" class="ArticleTeitle"> 
  </ Td> </ tr> <tr> <td height="25" colspan="2" valign="top" class="ArticleTeitle"> 

  ↑ Back 

Oreilly upload source components

  Abstract: Oreilly upload source components 

  </ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> upload open source components.    Function TempSave (ElementID) (CommentsPersistDiv.setAttribute ( "CommentContent" document.getElementById (ElementID). Value); CommentsPersistDiv.save ( "CommentXMLStore");) function Restore (ElementID) (CommentsPersistDiv.load ( "CommentXMLStore"); document . getElementById (ElementID). CommentsPersistDiv.getAttribute value = ( "CommentContent");) </ td> </ tr> <tr> 

  ↑ Back 

In the web application configuration HSQL database

  Abstract: In the web application configuration HSQL database 

  </ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> Thunder read some forum database, which is used HSQL database.    (Please download my entire directory test) 

  First, download from http://hsqldb.sourceforge.net/ HSQL1.7.3, which will be copied to your hsqldb.jar web applications WEB-INF/lib directory.    Write a document lightningboard.properties attributes, data will be stored in your web application TestHsql / hsqldb / lb_db under. 

  <table Width="681" border="0"> <tr> <td width="392"> # Database — — 
  DB.DRIVER = org.hsqldb.jdbcDriver 
  DB.URL = jdbc: hsqldb: webapps / TestHsql / hsqldb / lb_db 
  DB.USER sa = 
  DB.PASSWORD = 
  DB.MAX_CONNECTIONS = 30 

  Second, write configuration files used to read the above configuration database 
  Package lightningboard; 

  Import java.util.Properties; 
  Import java.io.InputStream; 
  Import java.io.IOException; 
  / ** 
  * LightningBoard configuration, the configuration file: 
  * "/ Lightningboard.properties." 
  * @ Version 0.3.5 
  * @ Author Xiaobo Liu 
  * / 
  </ Td> <td width="279" valign="top"> </ td> </ tr> </ table> 
  (Public class Configuration 
  Private Properties properties; 
  Private final static Configuration cfg = new Configuration (); 

  Private Configuration () ( 
  Properties = new Properties (); 
  InputStream is = null; 
  Try ( 
  Is = getClass (). GetResourceAsStream ( "lightningboard.properties"); 
  Properties.load (is); 
  ) Catch (Exception exception) ( 
  System.out.println ( "Can't read the properties file."); 
  Finally () 
  Try ( 
  If (is! = Null) 
  Is.close (); 
  ) Catch (IOException exception) ( 
  / / Ignored 
  ) 
  ) 
  ) 

  Public static Configuration getInstance () ( 
  Return cfg; 
  ) 

  Public String getValue (String key) ( 
  Return properties.getProperty (key); 
  ) 
  ) 
  Third, the database connection management, from a simple connection pool access connections. 
  Package lightningboard.db; 

  Import java.util.Vector; 
  Import java.sql.DriverManager; 
  Import java.sql.Connection; 
  Import java.sql.SQLException; 
  Import lightningboard.Configuration; 

  / ** 
  * Database Connection Manager 
  * @ Version 0.3.5 
  * @ Author Xiaobo Liu 
  * / 
  (Public class DBConnectionManager 
  Private final static DBConnectionManager instance = new DBConnectionManager (); 
  Private DBConnectionPool pool; 

  / ** 
  * Use singleton pattern, only return one instance of DBConnectionManager. 
  * @ Return DBConnectionManager 
  * / 
  Public static DBConnectionManager getInstance () ( 
  Return instance; 
  ) 
  / ** 
  * Get a connection 
  * @ Return Connection 
  * @ Throws SQLException this method 
  * / 
  Public Connection getConnection () (throws SQLException 
  Return pool.getConnection (); 
  ) 
  / ** 
  * Free a connection 
  * @ Param con connection 
  * @ Throws SQLException this method 
  * / Public void freeConnection (Connection con) throws SQLException ( 
  Pool.freeConnection (con); 

  ) 
  Private DBConnectionManager () ( 
  Init (); 
  ) 
  Private void init () ( 
  Configuration cfg = Configuration.getInstance (); 
  String db_driver = cfg.getValue ( "DB.DRIVER"); 
  String db_url = cfg.getValue ( "DB.URL"); 
  String db_user = cfg.getValue ( "DB.USER"); 
  String db_password = cfg.getValue ( "DB.PASSWORD"); 
  Int db_maxConn = Integer.parseInt (cfg.getValue ( "DB.MAX_CONNECTIONS")); 
  Try ( 
  Class.forName (db_driver); 
  ) 
  Catch (ClassNotFoundException ex) ( 
  System.out.println (ex); 
  ) 
  Pool = new DBConnectionPool (db_url, db_user, db_password, db_maxConn); 
  ) 

  / / Inner class 


  (Class DBConnectionPool 

  Private Vector freeConnections = new Vector (); 
  Private int maxConn; 
  Private int connNumb; 

  Private String URL; 
  Private String password; 
  Private String user; 

  Public DBConnectionPool (String URL, String user, String password, int maxConn) ( 
  This.URL = URL; 
  This.user = user; 
  This.password = password; 
  This.maxConn = maxConn; 
  ) 

  Public synchronized void freeConnection (Connection con) ( 
  FreeConnections.addElement (con); 
  ConnNumb -; 
  NotifyAll (); 
  ) 

  Public synchronized Connection getConnection () (throws SQLException 
  Connection con = null; 
  If (freeConnections.size ()> 0) ( 
  Con = (Connection) freeConnections.firstElement (); 
  FreeConnections.removeElementAt (0); 
  Try ( 
  If (con.isClosed ()) ( 
  Con = getConnection (); 
  ) 
  ) 
  Catch (SQLException e) ( 
  Con = getConnection (); 
  ) 
  ) 
  Else if (maxConn == 0 | | connNumb <maxConn) ( 
  Con = newConnection (); 
  ) 
  If (con! = Null) ( 
  ConnNumb + +; 
  ) 
  Return con; 
  ) 

  Private Connection newConnection () (throws SQLException 
  Connection con = DriverManager.getConnection (URL, user, password); 
  Return con; 
  ) 
  ) 

  ) 

  4, the following is the test jsp documents: Testhsql.jsp, Testhsql1.jsp (download) 

  <% @ Page contentType = "text / html; GBK charset ="%> 
  <% @ Page language = "java" import = "java.sql .*"%> 
  <% @ Page import = "lightningboard.db.DBConnectionManager"%> 

<%
  DBConnectionManager dbcm = DBConnectionManager.getInstance (); 
  Connection conn = null; 
  PreparedStatement ps = null; 
  ResultSet rs = null; 
  String sql = null; 
  Try ( 
  Conn = dbcm.getConnection (); 
  / / If there Table user to delete 
  Sql = "DROP TABLE IF EXISTS user"; 
  Ps = conn.prepareStatement (sql); 
  Ps.executeUpdate (); 
  / / Create Table 
  Sql = "CREATE TABLE USER (ID INTEGER, NAME VARCHAR (50), MOBILE CHAR (12))"; 
  Ps = conn.prepareStatement (sql); 
  Ps.executeUpdate (); 
  / / Insert data 
  Sql = "INSERT INTO user VALUES (?,?,?)"; 
  Ps = conn.prepareStatement (sql); 
  Ps.setInt (1, 1); 
  Ps.setString (2, "San"); 
  Ps.setString (3, "13912345678"); 
  Ps.executeUpdate (); 
  / / Data enquiries 
  Ps = conn.prepareStatement ( "SELECT * FROM user"); 
  Rs = ps.executeQuery (); 
  While (rs.next ()) ( 
  Out.println ( "ID:" + rs.getInt ( "id") + " 
");
  Out.println ( "Name:" + rs.getString ( "name") + " 
");
  Out.println ( "mobile phone number:" + rs.getString ( "mobile")); 
  ) 
  ) 
  Finally ( 
  If (rs! = Null) 
  Rs.close (); 
  If (ps! = Null) 
  Ps.close (); 
  If (conn! = Null) 
  Conn.close (); 
  ) 

%>

  OK!! Function TempSave (ElementID) (CommentsPersistDiv.setAttribute ( "CommentContent" document.getElementById (ElementID). Value); CommentsPersistDiv.save ( "CommentXMLStore");) function Restore (ElementID) (CommentsPersistDiv.load ( " CommentXMLStore "); document.getElementById (ElementID). CommentsPersistDiv.getAttribute value = (" CommentContent ");) </ td> </ tr> <tr> 

  ↑ Back 

String paging code

  Abstract: string paging code 

  </ Td> </ tr> <tr> <td width="527" height="35" valign="top" class="ArticleTeitle"> use examples: 
  StringPager pager = new StringPager (); 
  Pager.setSizePerPage (5); / / characters per page 
  Pager.setText ( "12345678901 ");// need a long text paging 
  Pager.setCurrentPage (2); / / Current Page 

  System.out.println (pager.getTotalPage ());// total number of pages 
  System.out.println (pager.getCurrentPagedText pages of the current string ());// 

  Note: Java-based concept of the length of the string, each page is displayed in English and Chinese, as are the length of a page. 
  All source documents: 


  Package examples; 
  / * 
  * @ (#) StringPager.java 1.00 2004-10-10 
*
  * Copyright 2004 All rights reserved. 
  * PROPRIETARY / CONFIDENTIAL. Use is subject to license terms. 
  * / 


  / ** 
  * StringPager, string tabs. 
*
  * @ Author Liuchangjiong 
  * @ Version 1.00 2004-10-10 
  * / 
  (Public class StringPager 

  / ** Current page number * / 
  Private int currentPage = 1; 

  / ** Paging needs of the long string * / 
  Private String text; 

  / ** Characters per page, the default is 200 * / 
  Private int sizePerPage = 200; 

  / ** Total number of pages * / 
  Private int totalPage; 


  Public StringPager () () 

  / ** 
  * Return to the pages of string. 
  * @ Return 
  * / 
  Public String getCurrentPagedText () ( 
  Try ( 
  If (getCurrentPage () <getTotalPage ()) ( 
  Return getText (). Substring ((getCurrentPage () - 1) * getSizePerPage (), 
  GetCurrentPage () * getSizePerPage ()); 
  ) Else if (getTotalPage ()> 0) ( 
  Return getText (). Substring ((getCurrentPage () - 1) * getSizePerPage ()); 
  ) 
  ) Catch (Exception e) ( 
  E.printStackTrace (); 
  ) 
  Return null; 
  ) 

  / ** 
  * @ Return Returns the current page number. 
  * / 
  Public int getCurrentPage () ( 
  If (currentPage <= 0) currentPage = 1; 

  Return currentPage; 
  ) 

  / ** 
  * Set up the current page, from the beginning. 
*
  * @ Param currentPage 
  * The number to set the current page number. 
  * / 
  Public void setCurrentPage (int currentPage) ( 
  If (currentPage <= 0) ( 
  CurrentPage = 1; 
  ) 
  This.currentPage = currentPage; 
  ) 

  / ** 
  * @ Return Returns the total number of pages, if there is no data on a return. 
  * / 
  Public int getTotalPage () ( 
  If (getText () == null) totalPage = 0; 
  TotalPage = (int) Math.ceil (1.0 * getText (). Length () / getSizePerPage ()) / / total number of pages 

  If (totalPage == 0) 
  TotalPage = 1; 
  Return totalPage; 
  ) 

  / ** 
  * @ Param totalPage 
  * The totalPage to set. 
  * / 
  Public void setTotalPage (int totalPage) ( 
  This.totalPage = totalPage; 
  ) 

  Public static void main (String [] args) ( 
  StringPager pager = new StringPager (); 
  Pager.setSizePerPage (5); 
  Pager.setText ( "12345678901"); 
  Pager.setCurrentPage (2); 

  System.out.println (pager.getTotalPage ()); 
  System.out.println (pager.getCurrentPagedText ()); 
  ) 

  / ** 
  * @ Return Returns the number of characters per page. 
  * / 
  Public int getSizePerPage () ( 
  Return sizePerPage; 
  ) 

  / ** 
  * @ Param sizePerPage 
  * The number of characters per page to set. 
  * / 
  Public void setSizePerPage (int sizePerPage) ( 
  This.sizePerPage = sizePerPage; 
  ) 

  / ** 
  * @ Return Returns the paging needs of the long string. 
  * / 
  Public String getText () ( 
  Return text; 
  ) 

  / ** 
  * @ Param text 
  * The need for paging long strings to set. 
  * / 
  Public void setText (String text) ( 
  This.text = text; 
  ) 
  ) 

  Below are the jsp call: testpage.jsp (download) 
  </ Td> <td width="175" valign="top" class="ArticleTeitle"> 
  </ Td> </ tr> <tr> <td height="25" colspan="2" valign="top" class="ArticleTeitle"> 

  ↑ Back 

JSP and interactive data JavaScirpt

  Abstract: JSP and interactive data JavaScirpt 

  </ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> <table width = "100%" border = "0" cellspacing = "0" cellpadding = " 0 "> <tr> <td width="277" height="86" align="center" valign="top"> </ td> <td width="407" valign="top"> 

  For WEB procedures, the front-end (JavaScript) and back-end (JSP / Servlet) is not shared data can only be a back-end process (JSP) to output data, generating pages to the front pages this time generation The JavaScript code may be only so-called jsp data.    Similarly, JavaScript, only to the data submitted to the backend JSP code, JSP process can be JavaScript data. 

  How to achieve it in the pages of the use of JavaScript in jsp data or jsp pages use the JavaScript data? 

  First, the JavaScript pages of data submitted to the background of how the procedures jsp 
  â‘  can JavaScript data to xxx.JSP? Var1 = aaa & var2 = bbb in the form of the parameters passed as a URL JSP procedures used at this time jsp 
  <% String strVar1 = request.getParameter ( "var1 ");%> can get to the JavaScript scripting transfer from the data; 

  â‘¡ form through the use of JavaScript added to hide domain information, and then use the form to the way the data transfer to the JSP procedures. 

  </ Td> </ tr> </ table> 

  Second, in the pages of JavaScript how to use the data behind the data JSP procedures 
  This relatively simple, and used directly in the JavaScript scripting <strVar1%% => jsp procedures will be in the data transfer to use the JavaScript scripting. 

  Third, reference to the following examples: 

  1, test.jsp 

  <% @ Page contentType = "text / html; gb2312 charset ="%> 

<%
  String s1 = "Hello"; 
  String s2 = "World!"; 
%>

  <script Language="JavaScript"> 
  /************************************************* The following 
  * JavaScript scripts, placed in the position of any of pages can be 
  * Insertclick () function to transfer access to JSP pages in the variable s1, 
  * JavaScript can then modify the value of this variable, and through the 
  * Post to the way JSP procedures to use. 
  ************************************************** *************/ 
  Function insertclick () ( 
  Var1 ="<%= s1%> "; 
  Document.forms [ "insertForm"]. Mc.value var1 = + document.forms [ "insertForm"]. Mc.value; 
  Document.insertForm.submit (); 
  ) 
  / / 
  </ Script> 

  <form Name="insertForm" method="post" action="get.jsp"> 
  <Input type = "hidden" name = "mc" value ="<%= s2%> "> 
  <input Type="button" value="提交" onclick="insertclick()"> 
  </ Form> 

  2, get.jsp 

<%
  String strVar1 = request.getParameter ( "mc"); 
  Out.print (strVar1); 
%>

  </ Td> </ tr> <tr> 

  ↑ Back 

Java file operations Daquan 3: attributes of a document

  Abstract: Java file operations Daquan 3: attributes of a document 

  </ Td> </ tr> <tr> <td width="513" height="35" valign="top" class="ArticleTeitle"> <% @ page contentType = "text / html; gb2312 charset ="% > 
  <% @ Page import = "java.util.Date, java.io. *"%> 

<head>

  </ Head> 
<body>
<%
  String path = request.getRealPath ( "/ article/article5a/example/filetest"); 
  File f = new File (path, "ReadData.txt"); 
  If (f.exists ()) ( 
%>
  <% = F.getName ()%> attributes are as follows: 


  Document length: <% = f.length ()%> 
  <% = F.isFile ()? "Document": "No documents"%> 

  <% = F.isDirectory ()? "Directory": "not a directory"%> 

  <% = F.canRead ()? "Can be read": "Do not read"%> 

  <% = F.canWrite ()? "Write": "Do not write"%> 

  <% = F.isHidden ()? "Hidden files": "no hidden files"%> 

  The document was last modified date: <% = new Date (f.lastModified ())%> 

<%
  Else () 
  F.createNewFile ();// under the current directory creation of a document entitled ReaData.txt 
%>
  <% = F.getName ()%> attributes are as follows: 


  Document length: <% = f.length ()%> 
  % = F.isFile ()? "Document": "No documents"%> 

  <% = F.isDirectory ()? "Directory": "not a directory"%> 

  <% = F.canRead ()? "Can be read": "Do not read"%> 

  <% = F.canWrite ()? "Write": "Do not write"%> 

  <% = F.isHidden ()? "Hidden files": "no hidden files"%> 

  The document was last modified date: <% = new Date (f.lastModified ())%> 

<%
  ) 
%>
  </ Body> 
  </ Td> <td width="171" valign="top" class="ArticleTeitle"> 
  </ Td> </ tr> <tr> <td height="25" colspan="2" valign="top" class="ArticleTeitle"> 

  ↑ Back 

Carp Forum

  Abstract: Carp Forum 

  </ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> <table width = "100%" border = "0" cellspacing = "0" cellpadding = " 0 "> <tr> <td width="286" height="86" align="center" valign="top"> </ td> <td width="398" valign="top"> 

  "Lei Yue Forum Version 2.0" to explain 

  [Statement] Since the issue of domain name service providers, "Carp Forum" will be used to the new names visit: http://www.liyunet.com/bbs/. 

  (New) Contact 

  QQ: 39666 7718 MSN: liyunet@hotmail.com EMAIL: liyunet@yeah.net 

  (New) demonstration Address: http://www.liyunet.com/bbs/ 
  (New) Download Address: http://www.liyunet.com/bbs/download.jsp 

  Version 2.0 updates: 

  </ Td> </ tr> </ table> 

  This version is a basic function of the Forum added, and add some new features, the restoration of the original internal interface and display a number of problems. 
  It also "Carp Forum," a new domain name to do that.    Suggest that you use liyunet.com visit. 

  Add "forum for generating static HTML pages" function (carp forum text version) and the contents removed and the posting of information unrelated things, the Forum makes browsing faster, more targeted content. 
  Add the "Report to moderator posts" function, the function for members, mainly against the illegal posting of reports and refuse to facilitate Moderators management, and increase the Tribune the involvement of members of the management. 
  Add "Send this page to a friend" function, to any forum that all the people can compare like to post links to their friends in the form of e-mail. 
  Add "the message sent packing" function, any forum here, if you want to post the text of the collection, the use of the function and the link will be posted with the text to a designated mailbox. 
  Add "Show Posts operating log" function, the moderator to facilitate administrator Show the management of the posts. 
  Add a new category within achieve JAVA MAIL email. 
  Add a new document type operation, generating HTML pages to achieve function. 
  Add User registration of users functional, try to use AJAX technology, it will be more functional use this technology to make. 
  Forum Member to amend repair information, exception handling and has not closed the database connection problems. 
  Manage Forum repair update data interface errors. 
  Revising internal category BUG. 
  Pages and the prospects of doing a simple easy-to-use changes. 

  [Note] 1, the use of "Generation Text version Carp Forum" before in the configuration file into the application's physical path, the system will default to the application directory generation / bbs / html /. 

  2, if you use email function, first in the configuration file configuration own e-mail information. 

  3, in order to avoid Chinese gibberish, we strongly recommend the use of Resin2.1.14 for testing servers, such as avoiding the use Tomcat.    Resin Application attention in the allocation of the time in the configuration file (the default for resin.conf) in the web-app-label attribute character encoding = 'GBK' guarantee with Chinese GBK transmission parameters. 
  MySQL4.1 or later there could be garbled question, please "carp forum," and "e-commerce technology" view, there are issues to resolve hash related articles. 
  In the process such as the use of other issues, go to the section of the postings, I will try my best to help you solve! 

  Carp Forum - E-commerce technology view: http://www.liyunet.com/bbs/list.jsp?forumID=2 
  Chinese carp forum to the relevant Description: http://www.liyunet.com/bbs/dispbbs.jsp?forumID=2&rootID=551&announceID=551 

  Liyunet.com "carp fishing nets," thank you for your support! 

  Version 1.0 updates: 

  This version is updated version of small, the main changes in the course of the operation of the BUG, organize forums source files, modify or rewrite parts of modules designed to improve the operating efficiency and stability.    Configuration files originally wanted to write XML documents, but readers feel efficiency is not very high, and now it is not necessary. 

  Major revisions are as follows: 

  Forum Posts repaired back, in the list can not be real-time display page error 
  List of repair due to the Forum cache dished out anomalies and individual errors 
  Removed in the list pages Member List, only shows the number of major information, and save resources for the provision of "online" links 
  List of the show online repair the problem hash 
  Home repair show officers in the list, "the current position" hash, and the user-level display hash issues 
  Home plate repair the left picture, as a new cache posts the same question 
  Posts pages repair show "indicates the print version of" functional errors 
  Restoration of the "Add Favorites" function mistakes 
  Add repair and modify the background section of the show features the wrong picture 
  The cache repair the problem, not the background changes to update the information forum issues 
  Repair transformation in the use of coding, the moderator announced hash issues 
  Repair the original forum posts can not be imported single quotes problems 
  Repair Forum Highlights page list of issues 
  Repair after posting back page heading shows that the problem can not be normal 
  Add Tour Posts, "a theme" and "Next" feature 
  Finishing prospects code JSP and JAVA class file format, aimed at improving efficiency 
……
  Some small changes not individually listed. 

  [Note] hash problem RESIN2.1.4, MYSQL4.1 and JDBC code and database connectivity through GBK circumstances will not arise. 
  Because the system can be configured to write the data into whether or Douchushuju before the coding conversion, in what format conversion to another kind of what kind of format. 
  Therefore, we must better use of the Forum, please read the following documents. 

  Download Address: 

  Http://bbs.on-ly.com/ 

  Platform: 

  In RESIN2.1.4, MYSQL4.1 under test pass.    RESIN recommended as a server. 

  If you use TOMCAT, as it defaults to ISO-8859-1 encoding transmission parameters, so-Chinese parameters need to be encoded into GBK that will be normal. 
  Modify / WEB-INF/systemconfig.properties documents 
  # Convert param encoding - ParamUtil.get * Parameter () 
  Param = no 
  Param.from = ISO-8859-1 
  Param.to = GBK 
  Yes can be of no 

  If you use other servers were garbled, check first whether the hash in the database, if it is requested to modify / WEB-INF/systemconfig.properties documents 
  # # 
  # Convert encoding - ParamUtil.get * Parameter () 
  # # 
  Encode = no 
  Encode.from = ISO-8859-1 
  Encode.to = GBK 
  Yes can be of no 

  It will be inserted into the data encoded into the database before.    If the database normal page for the hash, then modify / WEB-INF/systemconfig.properties documents 
  # SqlQuery.get * () 
  Decode = no 
  Decode.from = ISO-8859-1 
  Decode.to = GBK 
  Yes can be of no 

  I think in the following versions of all configurations to a centralized function module, more convenient to use! 

  Traditional need to support the import, or write to the Douchushuju before coding conversion, JDBC and databases using ISO-8859-1 format communications. 
  If there is to http://bbs.on-ly.com Chinese problems can be posted to the Forum! 

  Installation Method: 

  Decompression RESIN2.1.4, installed MYSQL4.1, mysql.txt SQL statement in the introduction to the database, the default name for the database: forum. 
  And the process of decentralization RESIN WEBAPPS directory. 
  Open sites. 

  Background note: 

  August of this year, accidentally e-commerce is a result of the advent of all the major websites to launch in the corresponding e-commerce platform, younger brother also like to own a small space, we will proceed to do his own "Lei Yue mall." use of spare time, and finally after three months, like a small point, the international domain name applications: on-ly.com on-ly.cn, and the online operation of the relatively normal and happy while feeling Shaoledian what … …, that is, its own small forum, said Zuojiuzuo, so I analyzed what they do a new, time and energy, are not feasible, such as the Internet DOWN that I find some of the more well-known Community forums, such as the JIVE, Tianyi community, Azerbaijan vegetables Forum, JIVE course did not have to say that, all doing very well, but now is a commercial version, and the program structure of the younger brother of the case more complicated, I just want to to a simple and practical small Dongdong, so no need to slaughter this line, took that to Tianyi community, it is indeed a rare good thing, whether practical, and its technology, did not have to say that, Even the structure of procedures are清淅level, the younger brother this level can understand the (great achievement), but one thing is not in line with my request, it is the allocation of more, I just want it is a "supporter "A dish forum to repeat it, simplicity, function well, with easy configuration, and I am really in need of almost, but (Why always But) I find the new online version of the official website will no longer seemed to provide support download from procedural mistakes and not place more, from that time, technology has advanced, but is now somewhat backward, operating efficiency to be improved.    With the above analysis, I decided that "A dish Forum" on the basis of the current use of new technologies, makes its operational efficiency and stability has been further improved, so I limited in the time and effort, add the following things: 

  Technology Forum set: 

  1, built-C3P0, proxool, dbcp database connection pool! 
  2, built-in a preliminary package of JDBC components to enhance the control of the data, paging, from limited data, and other coding into more convenient API! 
  3, the middle layers of data OSCache object cache, support EHCACHE! 
  4, related tools category, the use of developing more convenient, fast! 
  5, pages of the application OSCache cache. 
  6, page-refresh prospects. 

  In short, personal feeling efficiency is raised.    Of course, but also the common people to improve its quality. 

  [Note] Since everyone time and energy is limited, there now exists the wrong forum inevitable, so please everyone together perfect. 

  If there is any construction or good ideas, please contact me or visit online at the "Lei Yue Mun Forum" http://bbs.on-ly.com 

  My E-mail: on-ly@yeah.net, MSN: on-ly.com @ hotmail.com, QQ: 39666 7718 

  Main features: 

  (1). Prospects function 

  1. User registration: Only in terms of the Forum and fill out the registration information to users in a posting at the forum, the new user registration system will automatically prompts users to information, users are free to customize their head of information and signatures (support ubb label). 

  2. Landing users: may choose landing pages or landing directly in the postings on the landing, the system automatically record user login information, users can be released only landing postings. 

  3. Modifications: users can be their own landing of the original registration information changes. 

  4. Short message: landing users in the forums of any registered users to send short message, users can read the information and delete operations, upon receipt of text messages when the system will automatically remind. 

  5. Ranked Forum: Forum on the current support of the post in accordance with the number of registered users and registration time for Canada 

  6. Search Forum: Forum support for the title, content, the spokesman, id postings, the latest postings, the most popular postings, and other enquiries. 

  7. Released postings: landing (registered) users can lock in the absence of freedom within the forum postings, the Forum currently supports a variety of UBB grammar, textures, connectivity, insert Flash, html and debugging can be carried out the operation, you can choose quote responses and direct response, please see the use of specific uub help ubb related forums. 

  8. Resume postings: landing (registered) users can not lock on the theme of return, the speaker format Ibid. 

  9. Editor Notes: users can post their own published articles on the revision of moderators and administrators have the authority to edit all postings, the same class users can edit each other. 

  10. Online: detailed statistics users online accurate information, users can list browser, the system, 
  ↑ Back 

Java file operations Daquan 5: directory listed in the document

  Abstract: Java file operations Daquan 5: directory listed in the document 

  </ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> <table width="734" border="0"> <tr> <td width = " 728 "> </ td> </ tr> </ table> 
  <% @ Page contentType = "text / html; gb2312 charset ="%> 
  <% @ Page import = "java.io. *"%> 

<head>

  </ Head> 
<body>
<%
  String path = request.getRealPath ( "/ article/article5a/example/filetest"); 
  File d = new File (path); / / set up the current directory in the File object files 
  File list [] = d.listFiles ();// made on behalf of all the files in the directory object array File 
  Out.println ( "" + path + "directory paper: 
");
  For (int i = 0; i    If (list [i]. IsFile ()) ( 
  Out.println (list [i]. GetName () + " 
");
  ) 
  ) 
  Out.println ( " 
  "+ Path +" directory under the directory: 
");
  For (int i = 0; i    If (list [i]. IsDirectory ()) ( 
  Out.println (list [i]. GetName () + " 
");
  ) 
  ) 
%>
  </ Body> 

  </ Td> </ tr> <tr> 

  ↑ Back 

keep looking »