1、在Html的img src中要这样写
<!DOCTYPE html>
<html>
<head>
<title>register.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
</head>
<body>
<form action="">
用户名:<input type="text" name="username"/><br/>
密码:<input type="password" name="password"><br/>
验证码:<input type="text" name="checkcode"/> <img src="/myday06/servlet/ResponseDemo4"><br/>
<input type="submit" value="注册"/><br/>
</form>
</body>
</html>
2、在JSP的a href中要这样写
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<a href="/myday06/register.html">点点</a>
</body>
</html>
3、在servlet的sendRedirect中要这样写
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.sendRedirect("/myday06/servlet/ResponseDemo6");
}
4、在servlet的getRequestDispatcher中这样写
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.getServletContext().getRequestDispatcher("/servlet/ResponseDemo6").forward(request, response);
}