response.sendRedirect("http://www.foo.com/path/error.html"); |
<% response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); String newLocn = "/newpath/index.html"; response.setHeader("Location",newLocn); %> |
<jsp:forward page="/newpage.jsp" /> |
<jsp:useBean id="globals" scope="application" class="com.xxx.GlobalBean"/> |
<%@ page import="Java.util.*, Java.text.*" %> <HTML> <HEAD> <TITLE>JavaScript/" target="_blank">JSP to display the current time</TITLE> </HEAD> <BODY> The current time is: <% Date now = new Date(); out.println(DateFormat.getTimeInstance().format(now)); %> </BODY> </HTML> |
<%@ page import="Java.io.*" %> <%! String Mkdir(String path) { String msg=null; Java.io.File dir; // 新建文件对象 dir =new Java.io.File(path); if (dir == null) { msg = "错误原因:<BR>对不起,不能创建空目录!"; return msg; } if (dir.isFile()) { msg = "错误原因:<BR>已有同名文件<B>" + dir.getAbsolutePath() + "</B>存在。"; return msg; } if (!dir.exists()) { boolean result = dir.mkdirs(); if (result == false) { msg = "错误原因:<BR>目录<b>" + dir.getAbsolutePath() + "</B>创建失败,原因不明!"; return msg; } // 如果成功创建目录,则无输出。 // msg ="成功创建目录: <B>" + dir.getAbsolutePath() + "</B>"; return msg; } else { msg = "错误原因:<BR>目录<b>" + dir.getAbsolutePath() + "</b>已存在。"; } return msg; } %> <% String filepath = "/usr/home/hoyi/html/dir"; String opmsg = Mkdir(filepath); %> |
public static String returnToBr(String sStr) { if (sStr == null // sStr.equals("")) { return sStr; } String sTmp = new String(); int i = 0; while (i <= sStr.length()-1) { if (sStr.charAt(i) == '\n') { sTmp = sTmp.concat("<br>"); } else { sTmp = sTmp.concat(sStr.substring(i,i+1)); } i++; } return sTmp; } |