JSP learning lesson 1

Source: Internet
Author: User
Code:
  1. Download essential tools
  2. 1. Download and install myeclipse
  3. 2. Download and install Tomcat
  4. Configure the development environment
  5. 1. You can create a new web project (after myfirstwebproject is built, various directories and an "index. jsp" example are generated)
  6. File-> New-> Project-> myeclipse-> JAVA enterprise projects-> Web project
  7. 2. Configure Tomcat
  8. Window-> preferences-> myeclipse-> servers-> tomcat-> Tomcat 6.x-> fill in the relevant path of your tomcat.
  9. 3. Configure JDK for development
  10. Myeclipse will bring its own JRE runtime environment during installation, but if the version is too low, you need to set your own JDK. Tomcat 6.x-> JDK fill in the relevant path.
  11. 4. Deploy the newly created web project
  12. Select the deployment button-> select the project to be deployed-> Add Server-> finsh
  13. 5. Find servers in the preview of myeclipse
  14. Start two services: myeclipse and tomcat.
  15. 6. view the new project, open the browser and enter http: // 127.0.0.1: 8080/myfirstwebproject/to view the effect.
  16. Index. jsp file content
  17. The page attribute can specify some attributes of the JSP page, such as the language, the package to be used, and pageencoding.
  18. <% JSP code %>
  19. <%
  20. String Path = request. getcontextpath ();
  21. // Path indicates the folder name of the project/myfirstwebproject
  22. String basepath = request. getscheme () + ": //" + request. getservername () + ":" + request. getserverport () + path + "/";
  23. // Request. getscheme () obtains the protocol name: HTTP
  24. // Request. getservername () obtains the IP address of the server. The local host is localhost or 127.0.0.1.
  25. // Request. getserverport () returns the service port number: 8080.
  26. // Basepath = "http: // 127.0.0.1: 8080/myfirstwebproject /"
  27. %>
  28. <Base href = "<% = basepath %>">
  29. The base attribute in HTML is to set the base path of the link on the page. That is, when the path is set, basepath is added to the front by default.
  30. The Web. xml configuration file is very important. Do not modify it for the moment.

 

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.