The ancients cloud, "to do good deeds first, you must first sharpen the tools ". To do our job well and learn what we want to learn, we must first have a good application platform. For example, if you want to learn computer science, you need to have a computer. If you are an electrician, you need to have a lot of circuit boards and wires. If you want to learn management, you 'd better try it first. Can you manage the migrant workers who build bricks downstairs.
Well, if we want to learn JSP, we need to have a JSP development environment. Now we can build a new JSP development environment (J2EE.
This development environment is named jgn. That is, J2EE + glassfish + netbeans.
Why does Tomcat not need to be used in this development environment. First, the Tomcat environment has been set up, and the Internet is full, so there is no need to repeat it. Second, if it weren't for cool tomcat, my colleagues wouldn't take the initiative to give up website development-basically not for human use. Different machines perform the same operation and the results are different. I will not select ASP for one month first. Third, using glassfish as a server is really easy to build. You don't have to worry too much about it, and there won't be different cases of different machines.
Okay, so I started to build the platform.
We first download the relevant software from the Oracle website.
1. JDK 6 (required)
Http://www.oracle.com/technetwork/java/javase/overview/index.html
2. Java EE 6 SDK with JDK 7 U3 (comes with the glassfish open source Edition)
Http://www.oracle.com/technetwork/java/javaee/downloads/index.html
3. glassfish (optional)
Http://www.oracle.com/technetwork/java/javaee/downloads/index.html
4. netbeans (Java EE and glassfish are provided internally, but jdk6 must be installed)
Http://netbeans.org/downloads/index.html
PS: 2 provides an open-source glassfish version that can replace glassfish. Therefore, you can discard the 3rd items.
Well, I 'd like to ask, Java EE 6 SDK with JDK 7 U3 should already have JDK 6. In addition, jdk7 is also provided. Why do we need to install jdk6. This is mainly a problem. If you skip step 1 to install JDK 6, Run "Java EE 6 SDK with JDK 7 U3" and the computer displays the following information:
I tried to install the jre6 environment on my laptop, but it was not successful. I don't know why, so I installed JDK 6. I don't know why, so we should install JDK 6 first. In the future, you can select 6 or 7 development environments ~~~
1. Install JDK 6
It is very convenient to install JDK 6. Double-click the JDK 6 installation package you downloaded. Then, just like installing other program software, you can choose first.
These interfaces are basically displayed. Because JDK 6 contains JDK 6 and JRE 6, you can see that the interface appears twice. As long as you install other software before.
2. install Java EE 6 SDK with JDK 7 U3 (if glassfish is installed separately, it is similar to this one, so we will not introduce it again)
Double-click the installation package. Go to the installation page
After entering, we select "typical installation ". The requirement for selecting "typical installation" is that your ports 4848 and 8080 are idle. If not, you can change the port through custom installation.
Modify the installation directory according to your personal situation.
Update Tool, as long as the screen is not closed by the firewall, you don't have to worry about it. The default option of the application is "Next ".
Finally, let's take a look at the relevant installation content and click "Install ".
Start installation.
There is a problem in the installation, that is, "Update Tool Bootstrap is being configured. It may take several minutes. "after dinner, we may have played a game and been tortured by our girlfriend for half a day, and then came back to find that the progress has been stopped. Why? This is because your security tools or antivirus programs are in conflict with their installers-after all, glassfish is a new type of server system released by Oracle. Many security programs in China do not know each other, and they have been studying it. What should we do? It's easy to close these soft targets. The installation is completed quickly. (This type of problem occurred when I used 360, so I closed it all ).
Finally, the installation is complete.
The method for starting a server is simple:
Start> All Programs> java ee 6 SDK> Start application server.
Closing the server is also simple:
Start> All Programs> java ee 6 SDK> close application server.
After the server is built, we will start to build development tools. I suggest using netbeans, which is officially recommended by Java, because it is integrated, independent, convenient, and fast.
On the netbeans official website, we can see the following versions:
We can see that there are many versions. We basically choose Java ee.
If you have a lot of languages, you need a lot of work, or want to learn more in the future, I suggest you install all version of netbeans. This version is the most functional, and I also use this version. In Java EE and all versions, netbean integrates glassfish and Apache Tomcat. Therefore, if you do not need to learn how to build a server, you can directly install this version, instead of installing glassfish separately.
Okay. Now let's start the installation.
Double-click the netbeans installer to go to the installation page.
The terms must be accepted here
Select to install JUnit.
Select the installation path. One is netbeans IDE, and the other is the JDK integrated by netbeans itself (C and D are nowhere, but M is changed ).
Then, set the open-source glassfish version integrated by netbeans itself (C and D disks are no longer available, but M disks are changed ).
OK. Click "Next" until installation.
Congratulations:
OK. Let's test the effect.
Click the "netbeans" icon on the desktop to start netbeans.
Careful people can see that my current system has changed from XP to win7. I used to install Windows 7 on Windows 7, and the documents I wrote were also installed on Windows 7 computers. This made everyone feel confused.
On the netbeans page, choose File> new project from the menu bar ".
In the pop-up "new project" window, select "Java Web" in the category and select "Web application" in the corresponding project ".
Click "Next". Because it is used for the first time, the system needs to be automatically activated. For more information, see the relevant netbeans documentation. This is what everyone knows. Because it is automatic.
After the system is automatically activated, go to the "name and location" setting page. Enter the name of the project ). Then select "Project location" to store your program. Then, click "Next ".
In "servers and settings", if other "servers" are installed, we can choose. The default value is glassfish. By default, Java EE is used. The context path. skip this step unless otherwise required.
In the "Framework", since we are learning JSP at the beginning, we 'd better not use the framework. In the future, we will learn more about relevant specifications when learning relevant knowledge. So you don't need to worry about it here. If we have experience in MVC development, we can see that this netbeans provides support for mainstream J2EE frameworks. In addition, when we all start to learn the relevant frameworks, we also need to learn, if the new version of the Framework is installed. Because netbeans does not provide such a framework, it only provides some frameworks. To download and install other frameworks, go to the netbeans official website.
Finally, click "finish ". We can see that the system automatically creates a JSP page for us.
Start and run the JSP web program. The method is simple. Click "run main project" in the toolbar ". You can start it.
The startup method reminds us of the feeling of developing. Net with Visual Studio. The following is the startup demo page "Hello World ".
Okay, but we can see from the code that we use simple HTML code, not the JSP code we traditionally think:
<%-- Document : index Created on : 2012-3-3, 13:12:05 Author : yangzhencheng--%><%@page contentType="text/html" pageEncoding="UTF-8"%><!DOCTYPE html>
Okay, then we can use the following code:
<body>
Use the following code:
<body><% for(int i = 0; i < 10; i++){%>
After saving, refresh the browser and view the result as follows:
Is it very convenient. People with ASP development experience may feel very happy when they see <%>. Because <%> is required when writing ASP programs.
If you have experience developing C/C ++ and JavaScript, you will be more excited when you see the for loop.
But did we notice the first line of <% @ page contenttype = "text/html" pageencoding = "UTF-8" %>. This applies to almost all JSP pages. This is used to notify JSP engine-related page information. This tells the JSP Engine that the page is an HTML page that uses the UTF-8 code.
There are many images in today's content. You can accept them.