JSP dynamic page Description of the statements added by the IDE by default

Source: Internet
Author: User

When you create a new Web project, the IDE automatically generates INDEX.JSP in Webroot. index.jsp The default generated code content:

1<%@ page language="Java"import="java.util.*"pageencoding="iso-8859-1"%>2<% 3 String path = Request.getcontextpath (); 4 String basepath = request.getscheme () +"://"+request.getservername () +"  :"+request.getserverport () +path+"/"; 5%>6 7<! DOCTYPE HTML Public"-//w3c//dtd HTML 4.01 transitional//en">89Ten     <base href="<%=basePath%>"> One      A<title>my JSP'index.jsp'Starting page</title> -<meta http-equiv="pragma"Content="No-cache"> -<meta http-equiv="Cache-control"Content="No-cache"> the<meta http-equiv="Expires"Content="0"> -<meta http-equiv="keywords"Content="Keyword1,keyword2,keyword3"> -<meta http-equiv="Description"Content="This is my page"> -<!-- +<link rel="stylesheet"Type="Text/css"href="Styles.css"> -- + A    at<body> -This isMy JSP page. <br> -</body> -

You need to explain line 3rd, line 4th, and Line 10th.

The 3rd behavior, Request.getcontextpath (), is the name of the project you specified when you created it. The name is the name deployed to the server.

4th Behavior Request.getscheme () Gets the contents of the protocol (for example, HTTP), Request.getservername () gets the domain name of the server (IP address is also available), Request.getserverport () The port number of the server is obtained, and the last path is the Request.getcontextpath () of line 3rd, which gets the project name deployed on the server.

Take a look at the 4th line of code, the middle of the connection character, for example, give you a comparison you know what the meaning of,http://127.0.0.1:8080/kantai/

The 10th line of code means that if you have a aaa.html hyperlink on the Index.jsp page, the address you want to access when you click on the hyperlink is http://127.0.0.1:8080/kantai/aaa.html, you get it.

Waiting to be updated ...

JSP dynamic page Description of the statements added by the IDE by default

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.