我尝试使用谷歌搜索,我也搜索过StackOverflow,但我还没有找到这个问题的答案(也许我只是在搜索时不好?)。
Servlet A
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
PrintWriter out = response.getWriter();
String sortBy = request.getParameter("sortBy");
String orderBy = request.getParameter("orderBy");
// Send request and response if this link is clicked
out.println("<a href=\"/Fabflix/servlet/SortResults?sortBy="
+ sortBy + "&orderBy=" + orderBy + "\">Title</a>);
ArrayList<Movies> movies = ... //Fill up the movies arraylist
request.setAttribute("movies", movies);
}
SortResults Servlet
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
// Receive request here so I can call:
ArrayList<Movie> movies = (ArrayList<Movie>) request.getAttribute("movies");
}
如果仅在点击链接时才能从Servlet A
发送请求/回复?