JSP include Directive label

Source: Internet
Author: User
Tags square root

Suppose you need to embed a file somewhere in the JSP page, you can consider using this directive tag.

The directive label is as follows:

<%@ include file = "Names of files"%>

The purpose of this directive tag is to insert a file statically at the location where the instruction appears on the JSP page.

The

inserted must be accessible and available. That the file must be the same as the current jsp page in the same web service folder. The so-called static insertion refers to the current jsp The page and the inserted section are merged into a new jsp page, and then jsp engine again will this new jsp page translation becomes a jsp page file.

For example, suppose a JSP page uses an include directive to insert a jsp file. This JSP page that is inserted has a page directive that sets the ContentType property of the pages :

<%@ page contenttype= "text/html;charset=gb2312"%>

The current JSP page already uses the page directive to set the property value of the contentType property. The new merged JSP page has a syntax error, and will fail when translating the merged JSP page into the Java file.

The following example statically inserts a text file in the JSP page Hello.txt, the contents of which is "I am a student, I major in computer science and technology.". The text file must be in the same Web folder as the current JSP page .

<%@ page contenttype= "text/html;charset=gb2312"%>

The following is a JSP file that is inserted statically in the JSP computer.jsp

Computer.jsp content such as the following:

<form action= "" Method=post name=form><input type= "text" name= "OK" ><input type= "submit" value= "haha" name=submit></form><% String a=request.getparameter ("OK"); if (a==null) {     a= "1";} try{      Double Number=integer.parseint (a);  Out.print ("<BR>" +math.sqrt (number)); }catch (NumberFormatException e) {   out.print ("<BR>" + "Please enter numeric characters");%>

here are the test test.jsp

<%@ page contenttype= "text/html;charset=gb2312"%>



JSP include Directive label

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.