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