JSP is very similar to ASP. Both provide the ability to mix some program code in HTML code and explain and execute the program code by the Language engine. In an ASP or JSP environment, HTML code describes the display style of information, while program code describes the processing logic. The Programming Language in ASP is a script language such as VBScript, while JSP uses Java.
TRS and Its JavaBeans
TRS is the first Chinese full-text retrieval system in the world that adopts the "Parallel Computing" algorithm. Its full-text retrieval engine can provide performance not available in relational databases and can be used together with relational databases; because TRS can create full-text indexes for text content, it provides efficient full-text retrieval. Therefore, TRS can greatly improve the speed of website queries.
TRS JavaBeans is developed based on Java component technology-JavaBeans and has good cross-platform features. This article describes how to use JSP, TRS, and JavaBeans to build a Web.
Configure TRS JavaBeans
Take WebLogic5.1.0 under NT as an example.
1. Install WebLogic5.1.0
2. Modify startWebLogic. cmd.
Change "set PRE_CLASSPATH =" to "set PRE_CLASSPATH = % full path % of TRSBean. jar; % full path % of TRSDemo. jar ".
For example, if TRSBean. jar is located in the C: TRSJavaBeanslib directory, change the statement:
Set PRE_CLASSPATH = C: TRSJavaBeanslibTRSBean. jar
3. Modify weblogic. properties
Remove the # Before # weblogic. httpd. register. servlets = weblogic. servlet. ServletServlet.
Remove the "#" before the following statement:
# Weblogic. httpd. register. *. jsp =
# Weblogic. servlet. JSPServlet
# Weblogic. httpd. initArgs. *. jsp =
# PageCheckSeconds = 1,
# CompileCommand = C:/java/bin/javac.exe,
# WorkingDir = D:/weblogic/myserver/classfiles,
# Verbose = true
Then, change "compileCommand = C:/java/bin/javac.exe" to "compileCommand = JAVA _ PATH/bin/javac.exe,", where JAVA_PATH is the installation root directory of the actual JDK used.
4. install DEMO
Copy all the DEMO directories of the TRSJavaBeans installation package to the Directory D:/weblogic/myserver/public_html.
After completing the above configuration, we can enter the design and development stage.
Development example
Set the database to "news. investment dynamics". The fields are "title", "content", "date", and "number" (uniqueness field ).
Take the details of a specific record as an example. For paging display, full-text retrieval, and BBS, the length is limited and will not be repeated. Interested users can try it on their own. For the actual operation result, see www.exin.net or Beijing investment platform (www.bjinvest.gov.cn ).
The jsp program is as follows:
<HTML>
<HEAD>
<TITLE> News </TITLE>
<Link REL = "stylesheet" href = "mycss.css" TYPE = "text/css">
<META content = "text/html; charset = GB2312" http-equiv = Content-Type>
<% @ Page import = "com. eprobiti. TRS. *" %>
<% @ Page import = "java. util. *" %>
<Jsp: useBean id = "TRSConn" scope = "session" class = "com. eprobiti. TRS. TRSConnection"/>
<Jsp: useBean id = "TRSRS" scope = "page" class = "com. eprobiti. TRS. TRSResultSet"/>
</HEAD>
<BODY>
<%
String item_id = request. getParameter ("id ");
// The parameter id is transmitted from the URL or the form hidden field of the previous file.
String dbname, ip, port, username, password;
Dbname = "news. Beijing news ";
// TRS Database Name
Ip = "202.123.166.99"; // TRS Server IP Address
Port = "8888"; // TRS server port
Username = "yourname ";
// Retrieve the username of "news. Beijing news"
Password = "yourpassword ";
// Password corresponding to the user name
String filter = "No. =" + item_id;
// Define search conditions
Try {
If (TRSConn. connect (ip, port, username, password )){}
// Establish a connection with the TRS Server
Else {
Out. println ("Connection failed! N ");
}
TRSRS = TRSConn.exe cuteSelect (dbname, s1, "", "", null, 0, 0, false );
// Execute the query operation to generate a record set
} Catch (TRSException TRSe ){
Out. println ("ResultSet connection failed! N ");
}
Try {
TRSRS. moveFirst ();
// Record location
%>
<P>
<Center>
<Table width = 80%>
<Tr align = center>
<Td> <% = TRSRS. getString ("title") %>
</Td>
</Tr>
<Tr align = center>
<Td> <% = TRSRS. getString ("date") %>
</Td>
</Tr>
<Tr>
<Td> <% = TRSRS. getString ("content") %>
</Td>
</Tr>
</Table>
</Center>
<P>
<%
TRSRS. close ();
} Catch (TRSException TRSe ){}
%>
</Body>
</Html>