1.重定向网页
sendRedirect("*.jsp"); sendError(int number,[Stirng msg]);
实例:
String username=request.getParameter("name");
String password = request.getParameter("pwd");
if(!username.equals("") && !password.equals("")){
response.sendRedirect("sindex.jsp");
}else{
response.sendError(500,"请输入登录验证信息");
}
2.设置Http响应报头 http://www.w3.org/Protocols/ 报头英文版解释,示例代码及运行效果
<%@ page contentType="text/html; charset=gb2312" %>
<html><body>
<%
if(request.getParameter("submit1")!=null){
response.setContentType("application/msword;charset=gb2312");
}
%>
平平淡淡才是真!
快快乐乐才是福!
<form action="" method="post" name="form1">
<input name="submit1" type="submit" id="submit1" value="保存为word"/>
</form>
</body></html>