How to use JSP to build a Web site

Source: Internet
Author: User
Tags server port

JSP is very similar to ASP. Both provide the ability to mix some kind of program code in HTML code, and the language engine to interpret the execution code. In an ASP or JSP environment, HTML code is primarily responsible for describing the display style of information, while program code is used to describe the processing logic. The programming language under ASP is a scripting language such as VBScript, and the JSP uses Java.

TRS and its JavaBeans

TRS system is the first Chinese Full-text retrieval system with "parallel Computing" algorithm, its Full-text search engine can provide the performance of relational database, and can be used in conjunction with relational database, because TRS can establish full-text indexing for text content and provide efficient full-text retrieval capabilities. So using TRS can greatly improve the query speed of the website.

TRS JavaBeans is developed based on Java component Technology--javabeans with good cross-platform features. This article describes the process of building a Web using JSP, TRS, and JavaBeans.

TRS JavaBeans Configuration steps

Take NT Lower WebLogic5.1.0 as an example to explain.

1. Install WebLogic5.1.0

2. Modify Startweblogic.cmd

Change "Set pre_classpath=" to "full path% of full path%;%trsdemo.jar of Set Pre_classpath=%trsbean.jar".

For example, if Trsbean.jar is located in the C:trsjavabeanslib directory, change the statement to:

Set Pre_classpath=c:trsjavabeanslibtrsbean.jar

3. Modify Weblogic.properties

Take the statement: #weblogic. Httpd.register.servlets=weblogic.servlet.servletservlet before the # number removed.

Remove the "#" number 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 replace "Compilecommand=c:/java/bin/javac.exe," with "Compilecommand=java_ Path/bin/javac.exe," where Java_ Path is the installation root directory of the actual JDK used.

4. Install Demo

Copy the demo directory of the Trsjavabeans installation package to the d:/weblogic/myserver/public_html directory.

Once the above configuration is complete, we can enter the design and development phase.

Development example

Set the database as: "News. Investment dynamics", with the field "title", "Content", "date", and "number" (unique field).

To show the details of a specific record as an example, as for the paging display, Full-text search and BBS, space limit, no longer repeat, interested users can try their own. The actual results can be obtained from the Www.exin.net Network (www.bjinvest.gov.cn) or the Beijing investment platform.

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 passed from the URL or from the form hidden field of the previous file.

String Dbname,ip,port,username,password;

dbname = "News Beijing Press";

TRS database name

ip= "202.123.166.99"; TRS Server IP

port= "8888";//trs Server port

Username= "Yourname";

You can retrieve the user name for news.

Password= "YourPassword";

The password for the user name

String Filter = "number =" +item_id;

Define search criteria

try {

if (Trsconn.connect (Ip,port,username,password)) {}

Establish a connection with the TRS server

else {

OUT.PRINTLN ("Connection Connection failed!) n ");

}

Trsrs = Trsconn.executeselect (Dbname,s1, "", "", NULL, 0, 0, false);

Perform a query operation to generate a recordset

catch (Trsexception trse) {

OUT.PRINTLN ("ResultSet Connection failed!) n ");

}

try {

Trsrs.movefirst ();

Record positioning

%>

<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>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.