可以通过forward来实现,代码如下:
http://localhost:8080/myapp/select.jsp
select.jsp:
<a href="/myapp/upload">上传</a>
<a href="/myapp/listfile">下载</a>
web.xml:
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MyTest extends HttpServlet {
private static final long serialVersionUID = 1L;
@Override
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
if(request.getServletPath().equals("/listfile")){
getServletContext().getRequestDispatcher("/WEB-INF/listFile.jsp").forward(request,response);
}else if(request.getServletPath().equals("/upload")){
getServletContext().getRequestDispatcher("/WEB-INF/upload.jsp").forward(request,response);
}
}
}
2012年11月19日 07:52