内容发布更新时间 : 2024/12/23 0:39:25星期一 下面是文章的全部内容请认真阅读。
大连交通大学信息工程学院
毕业设计(论文)外文翻译
学生姓名 刘恋 专业班级 软件工程08-2班
指导教师 王鑫 翟悦 职 称 高工 讲师
所在单位 信息科学系软件教研室
教研室主任 刘瑞杰
完成日期 2012 年 4 月 13 日
The JSP basic learning material
1. JSP technology overview
In from the official launch JSP (JavaServer Web), then the new Web application development skills quickly to cause the attention of people. The JSP for creating highly dynamic Web application provides a unique development environment. According to the statement from can adapt to the market, the JSP WebServer, including I can with Apache IIS4.0, 85% of server products. Even if you the ASP \we believe, paying attention to the development of JSP are still very be necessary.
(1)JSP simple compared with ASP
The JSP and Microsoft of ASP technology are very similar. Both offer in HTML code mixed some code, by the language engine interpretive execution code's ability. In ASP and JSP environment, HTML code is mainly responsible for describe information display, and program code is used to describe handling logic. Normal HTML page only depends on the Web server and the ASP and JSP page need additional language engine analysis and implementation program code. The program code to be executing embedded into HTML code, then the message to all browsers. ASP and JSP are facing the Web server technology, the client browser does not need any additional software support.
ASP programming language is VBScript such scripting language, JSP use is Java, this is both one of the most significant differences. In addition, ASP and JSP more essential difference: two languages in a totally different way engine handling page embedded program code. In the ASP, VBScript code is ASP engines interpret execution; In the JSP, code has been compiled into Java virtual machine by Servlet and execution, the compiler operation is only on the JSP page first request happen.
(2)Dimension of running environment
From the JSP page in http://www.javasoft.com/products/jsp/index.html, from here can also download the JSP specification, these standard defines the supplier in creating JSP engine when must comply to some rules.
Execute JSP code needed on the server installation JSP engine. Here we use is from the Development Kit (JavaServer Web JSWDK). To facilitate learning, this package offers a lot for modification examples. JSWDK after installation, just need to perform startserver command can server. The default configuration server in the port 8080 surveillance, use http://localhost:8080 can open default page.
In running the JSP sample page before installation, please pay attention to the JSWDK directory, especially \subdirectories of content. Execute the sample pages, here can see
how the JSP page are converted into Java source file, then compiled into scale-up file (i.e. Servlet). JSWDK packages examples in the page is divided into two categories, they or JSP files, or is included in a form of HTML files, these forms all by JSP code processing. And as the Java, JSP ASP code are executed on the server. Therefore, in the browser use \view source\menu is unable to see the JSP code, can see the results HTML code. All the source code examples are by a single \
Eclipse is an open source, based on a Java extensible development platform. Eclipse it just a framework and a set of service, used to construct the Development environment through plug-ins components, the key is Eclipse comes in a standard plugin sets, including Java Development Tools (Java Development Tools, JDT). The Eclipse is developed by IBM alternative commercial software for the next generation of Java Visual age-related IDE development environment, November 2001 contribution to the open source community, now by a non-profit software vendors alliance Eclipse Foundation (Eclipse Foundation) management.
(3)JSP page examples
Below we analyze a simple JSP page. You can JSWDK examples in the directory create another directory store this file, the file name can be arbitrary, but extensions must serve. JSP. From the code below the list can see, except the JSP page than ordinary HTML page more Java code outside, both has the same basic structure. Java code is through < % and % > symbols to join in the middle of the HTML code, its main function is to generate and display a from 0 to 9 string. In the string in the front and rear of the HTML code that some are through the text output. < HTML>
< HEAD>< TITLE>JSP PAGE < /TITLE>< /HEAD> < BODY>
< %@ page language=\ < %! String str=\ < % for (int i=1; i < 10; i++) { str = str + i; } %>
JSP Before out。 < P> < %= str %> < P>
JSP After out。 < /BODY> < /HTML>
The JSP page can be divided into several parts for analysis.
First is the JSP instructions. It describes the basic information of the page, such as the use of language, whether to maintain conversation status, whether to use cushion etc. The JSP instructions by < % @ beginning, % > over. In this example, directive \>\simply defines this example is using Java language (at present, in the JSP specification in Java is the only support language).
Next came the JSP statement. The JSP statement may be regarded as the definition of this level of variables and method of place. The JSP statement by < %! Start, % > over. If the cases of \String STR =\just like in ordinary Java class declaration in the same member variables.
Located in < % and % > between the code block is to describe the JSP page handling logic of Java code, such as the example shown the seas cycle.
Finally, located in < % = and % > between code is called the JSP expression, such as the example of \embedded HTML pages of simple method.
2. The session state management
The session state maintain is the Web application developers must face the problem. There are various ways can be used to solve this problem, if use Cookies, hidden form input domain, or directly to the URL in additional status information. Java Servlet provides a continuous effectively in multiple requests the conversation between objects, the object allows users to store and retrieve the session state information. The JSP also support Servlet of this concept.
In the JSP from guidelines can see many relevant implied object instructions (implicit meaning is that these objects can directly referenced, do not need explicit statement, also do not need special code to create actually cases). For example that object, it is the HttpServletRequest a derived class. The object contains all the related current browser requests information, including Cookies, HTML form variables, etc. Session object is also such a hidden objects. This object in the first JSP page is loaded, and automatically created by related to that objects. The conversation with ASP object of similar, JSP session object for those who hope that through multiple pages to complete a affairs application is very useful.
To illustrate the session object concrete application, next we use three pages more than a page of simulation Web application. The first page (q1. HTML) contain only a requirement to enter your user name HTML forms, the HTML code is as follows: < HTML> < BODY>
< FORM METHOD=POST ACTION=\
Please write your name:
< INPUT TYPE=TEXT NAME=\ < INPUT TYPE=SUBMIT VALUE=\ < /FORM> < /BODY> < /HTML>
The second page is a JSP page (q2. JSP), it through that object extraction in q1. HTML form thename value, it will be stored for name variable, then will the name value saved to the session objects. Session object is a name/value pairs set, here, name/value pairs of the name is \namely for name values of the value of the variable. Due in session during the session object is effective until, so here preserved variables on subsequent page as well. Q2. JSP another task is to ask the second question. Below is its code: < HTML> < BODY>
< %@ page language=\ < %! String name=\ < %
name = request.getParameter(\ session.putValue(\ %>
What is your name: < %= name %> < p>
< FORM METHOD=POST ACTION=\ What do you want to eat?
< INPUT TYPE=TEXT NAME=\ < P>
< INPUT TYPE=SUBMIT VALUE=\ < /FORM> < /BODY> < /HTML>
The third page is a JSP page (percentile. JSP), main task is to show the q&a results. It from the value of the thename session object extraction and display it, prove the value in the first though page input, but through session object is maintained. Percentile. JSP another task is to extract the user input at the second page and displays it: < HTML> < BODY>