A JSP beginner's learning process detailed

Source: Internet
Author: User
Tags iis interface variables version port number tomcat tomcat server apache tomcat
js| Beginner | process | detailed Preface

From now on I'm going to write down the process of learning JSP. I collected these things from books and the internet, and I wrote them for my reference as a beginner.

Please allow me to say something that is not of interest to the reader. Please skip to Chapter one or chapter two directly.

I graduated from university in July 2003, after four years of computer science, because the basic is a liberal arts school of Computer Science, the school girls less Boys more study atmosphere is very affected, so you can imagine my graduation level. In school, most of the learning is boring computer theory knowledge, although I know that it is useful, but really not interested, I am interested in coding, so I learned a semester of Pascal, and made a semester of C (learning C is enthusiastic, or even teach the teacher to allow or say support I skipped class back to code), with pointers, Linked list, no, abandoned, instead of learning C + +, not half a month, when the "Object", "Class", "Inheritance", not, and then abandoned, eventually failed, helpless under, day and night games, do not think enterprising, do not count, graduation.

After this until now has been in a Nakata information center work, because it is "public institutions", so the work is very busy, the first half of the year to learn two months of HTML, and then learn one months of ASP, due to lack of pressure, eventually gave up. Until our unit started a project-e-government, my situation has changed.

We found two companies to develop software for us, the leader said let me follow, learn to write things, because that year C gave me the shock is too big, I have decided that they are not that piece of material, is not the talent of the program, so some reluctance, but finally because too busy and unwilling to mind their own "no technical content", Finally chose the learning JSP. I looked for us to develop software a programmer friend, to him to come to Tomcat, JSDK and pirated Oracle, writing platform on the temporary use of my more familiar with the Dreamweaver, English is also poor, useless jbuilder, jcreator what, as for the information, no, Only the network, I started my JSP trip.

I did not think is that a little bit of the C, HTML, ASP let me not very laborious to enter (near) JSP door, this speed at least surprised me.

It is worth to note that: I learn JSP is entirely from the example, this prior to my theoretical knowledge of the basic zero, so I understand the code (to a large extent in the annotation) is to use their own "dialect", rather than "terminology." My principle is that this text can make the same beginners and I can read.

For a man without foundation, you say to him "class", "Object", "interface", "inherit" these nouns, he is incomprehensible, because they are too abstract, so I have to through the examples and not standardized language to make them specific.

Because my level is really limited, there may be a lot of mistakes, especially in the understanding of some "code", but I dare to take out the brick, I hope to have enthusiastic master hard to throw Jade ^_^ This is my mailbox: windowsmx@sohu.com.

Finally, I would like to thank the Internet and the programmers who share their experience, the leadership of my unit, my colleagues, the programmer friend Sun Yu, the University friend Peng Tao and so on.

Chapter One configuring the server environment

The JSP full name is the Java Server pages (not the abbreviation for JavaScript, JavaScript is a scripting language in the Java language), and in my words, it's a bunch of code (or code specifications) that is used on Web browsers, From this perspective and make an ASP similar. It's not a programming language, but it needs a programming language to write the programs, just as ASP uses VB as a programming language, and JSP uses the Java language.

Install the software:

Since JSP uses Java, then our server operating system of course must have the corresponding Java environment, otherwise how do we use Java provided "library functions"? JDK is this thing, we can download it from Sun Company's website, install it to the operating system first (my operating system is Windows XP Professional SP2), my installation directory is: D:\j2sdk1.4.2_ 07, after loading we also need to configure, this step in the following.

We also need to install a Web server, we beginners can generally choose Tomcat as a JSP Web server. What is a Web server? If you have a little understanding of ASP, you will know that IIS this thing--iis is the ASP's Web server, so tomcat for JSP, it is equivalent to ASP IIS. I am using Tomcat5.0, you can also use a higher version, note that you have to install the JDK before installing it, my Tomcat installation directory is: D:\Tomcat 5.0.

Configuration:

Right--"My Computer"-"Properties"-"advanced"-"environment variables", there are user variables and system variables, to tell you the truth, the main role of user variables I am not very clear, but the system variables must be very important, through the "new" or "edit", my related user variables are like this:

Classpath ——.; D:\j2sdk1.4.2_07\lib\tools.jar;d:\j2sdk1.4.2_07\lib\dt.jar;
Java_home--d:\j2sdk1.4.2_07
Path--d:\j2sdk1.4.2_07\bin;d:\j2sdk1.4.2_07
My related system variables are:
CATALINA_HOME--D:\TOMCAT 5.0
Classpath ——.; D:\j2sdk1.4.2_07\lib\tools.jar;d:\j2sdk1.4.2_07\lib\dt.jar;
Java_home--d:\j2sdk1.4.2_07
Path--d:\j2sdk1.4.2_07\bin;d:\j2sdk1.4.2_07 (Add this sentence, not the final value)
TOMCAT_HOME--D:\TOMCAT 5.0

After the installation of Tomcat, there will be an extra Apache Tomcat service in the Windows system's services, which is automatic, and you can change it manually so that you can save some system resources when you're not using it. Now that you've changed it to Manual, how do you start it? Find these two files: D:\Tomcat 5.0\bin\startup.bat and D:\Tomcat 5.0\bin\shutdown.bat, the first one is to start Tomcat's batch file, and the last one is off.

When you install Tomcat you may find that there is a place in the installation that can change the port number by default, "8080", and you should pay attention to this port number when you debug the program. After the above configuration is complete, you can see if it is successful: start the Tomcat server first, then enter in the Web address bar: http://localhost:8080/(client and server are the same machine), the installation is successful you will see Tomcat welcome interface. You can also use your IP or machine name, such as my IP is 172.16.20.30, machine name is Ringz, then enter the following two kinds of forms are feasible: http://172.16.20.30:8080/,http://ringz:8080/.

Chapter II Mild Contact Server.xml

<%@ page contenttype= "text/html; charset=gb2312 "language=" java "errorpage=" "%>
<%
Out.print ("The Japanese should be wiped out");
%>

This file is printed on the page and you can even write it in Notepad, but the main question is where the file (such as test.jsp) is placed. The default directory for Tomcat seems to be D:\Tomcat 5.0\webapps\jsp-examples, The early 4.1 version of the directory is examples, put this file under Jsp-examples, open the Tomcat server, in the address bar input: http://ringz:8080/jsp-examples/test.jsp.

Now the question is: I do not want to use 8080 of this port, directly with http://ringz/jsp-examples/test.jsp how good ah. This first depends on whether your 80 port is occupied, in general, your machine does not have IIS installed or the IIS service is stopped, 80 ports can be used. The specific modification method is as follows: Open this file--d:\tomcat 5.0\conf\server.xml, you will find such a piece of code:
<connector port= "8080"
maxthreads= "minsparethreads=" maxsparethreads= "75"
Enablelookups= "false" redirectport= "8443" acceptcount= "100"
debug= "0" connectiontimeout= "20000"
Disableuploadtimeout= "true"/>
Change the port= "8080" to port= "80", save the file, restart the Tomcat server, and if it starts, it can use 80 ports, and if the Tomcat startup window is turned off in a flash, It means that port 80 is already occupied (this is based on the premise that the Server.xml file has no errors, and if there are other errors, such as a "/>"). In this way you can switch to other unused ports, for example, the company that gave us the software was tested with Port 7988. In addition to port 80, the other ports are indicated in the address bar, and 80 is not used because it is the default port for the HTTP protocol.

The next question is: I don't want to put the written. jsp file under D:\Tomcat 5.0\webapps\jsp-examples? This also requires modifying the Server.xml file: if your. jsp file is placed under E:\MYJSP, add such a piece of code between the <Host></Host> of the file: <context path= "/myjsp" Docbase= "E:\MYJSP" debug= "0" reloadable= "true" crosscontext= "true"/> (note that you want to match the case of the file name). This allows you to run the file in the address bar by typing http://ringz/MyJsp/test.jsp (same note-case). If changed to: <context path= "" docbase= "e:\MyJsp" debug= "0" reloadable= "true" crosscontext= "true"/&gt, so enter http://in the address bar Ringz/test.jsp on the line.

If you are interested, you can see what the page will look like only when you enter Http://ringz.

Now you may have this idea: one of my systems (or a site) has a fixed entry file, such as login.htm, I want to open the file only in the address bar input http://ringz, what about this? This can be done by modifying and server.xml in the same directory as the Web.xml file: Generally in this file at the bottom of the code:

<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
All you have to do is change one of them to <welcome-file>login.htm</welcome-file>.

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.