1.可以使用:
| 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; } |
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器