---restore content starts---
1.application usually replaced with This.getservletcontext ()
2.appllication has a very useful function, Getrealpath (), to get an absolute path in order to implement the JSP file operation
String fileName = This.getservletcontext (). Getrealpath ("/") + "Note" + File.separator + name;
3. Save the file with the PrintStream class object
File File = new file (fileName);
if (!file.getparentfile (). exists ()) {
File.getparentfile (). mkdir ();
}
PrintStream PS = null;
PS = new PrintStream (new FileOutputStream (file));
Ps.println (filecontent);
Ps.close ();
3. Scanner class object for reading files
Scanner scan = new Scanner (new FileInputStream (file));
Scan.usedelimiter (";");
StringBuffer buf = new StringBuffer ();
while (Scan.hasnext ()) {
Buf.append (Scan.next ()). Append ("<br>");
}
Scan.close ();
<%=buf%>
4. Get Server Environment Properties
<%
Enumeration ENU = This.getservletcontext (). Getattributenames ();//Get All Properties
while (Enu.hasmoreelements ()) {
String name = (string) enu.nextelement ();
%>
<%
}
%>
JSP Learning notes-built-in object application